Solved

Unix Script Problem

Posted on 2004-09-23
5
446 Views
Last Modified: 2010-04-21
This script retrun values into a txt file. I need to insert a delimter "^", Currently the delimiter is only added to the headings. How can I add it to the end of the actual data.

e.g

Val1  val2  val3
ss^  dd^   mm^

select substring(Task_Type,1,10)"Type^",
       substring(Job_Name,1,10)"Jobname^",
       substring(MemName,1,30)"Member^",
       substring(W_Day_Str,1,15)"Week Days^" ,
       substring(Days_Cal,1,10)"Calendar^",
       substring(Group_Name,1,30)"Group^",
       substring(Description,1,60)"Description^",
       substring(Node_Id,1,12)"Data Center^" from def_job

Thanks
0
Comment
Question by:xy15973
  • 2
5 Comments
 

Expert Comment

by:pmathinos
ID: 12132625
Change this line to reflect your table/columns and try it:

e.g:
SELECT SUBSTR(NUMDATA,4,4)||'^ '||UPLINK||'^ '||DOWNLINK||'^ '||TOTAL
FROM TEMP_TABLE

will give you:

9480^ 0^ 0^ 0
9478^ 1170^ 58^ 1228
9470^ 0^ 0^ 0
9422^ 0^ 0^ 0
9473^ 0^ 0^ 0
9445^ 1281^ 366^ 1647
9472^ 0^ 0^ 0
9480^ 0^ 0^ 0
9479^ 0^ 0^ 0

pmathinos.
0
 

Author Comment

by:xy15973
ID: 12158757

Will this work?

select substring(Task_Type,1,10)||"^"||Type ,
       substring(Job_Name,1,10)||"^"||Jobname ,
       substring(MemName,1,30)||"^"||Member ,
       substring(W_Day_Str,1,15)||"^"||"Week Days" ,
       substring(Days_Cal,1,10)||"^"||"Calendar",
       substring(Group_Name,1,30)||"^"||"Group",
       substring(Description,1,60)||"^"||"Description",
       substring(Node_Id,1,12)||"^"||"Data Center" from def_job
go
0
 

Accepted Solution

by:
pmathinos earned 200 total points
ID: 12167640
double quotes will not work. Use single quotes to append Strings to columns...

To get the column headers as well use a separate SQL query.

Save the following to an temp.sql file, start your SQL session and type
SQL> @temp.sql
to execute the file...
"output.dat" will contain your '^' - delimited report

-- start of sql file

set heading off
set linesize 100
set feed off
set echo off
set show off
set pagesize 0
set space 0
set trimspool on

SPOOL output.dat

select 'Type'||'^'||'Jobname'||'^'||'Member'||'^'||'Week Days'||'^'||'Calendar'||'^'||'Group'||'^'||'Description'||'^'||'Data Center' from dual;

select      substring(Task_Type,1,10)||'^'||
      substring(Job_Name,1,10)||'^'||
      substring(MemName,1,30)||'^'||
      substring(W_Day_Str,1,15)||'^'||
      substring(Days_Cal,1,10)||'^'||
      substring(Group_Name,1,30)||'^'||
      substring(Description,1,60)||'^'||
      substring(Node_Id,1,12)
from def_job;

SPOOL OFF

-- end of sql file


0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sudo logging 5 93
Unix, date minus 1, 2 or 3 days (last working day) 11 53
ACL in Solaris 10 & AIX V6.1 to circumvent application required  grp:rwx 9 114
aix unix tar error 3 67
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question