help with header of sql


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with header of sql
# 1  
Old 12-02-2005
help with header of sql

i have this script here..
text=/d:/...../1.txt

ORACLE_HOME/bin/sqlplus -S............
...................................................

spool $text;
select
item || '|' ||
ord_no || '|' ||
price || '|' ||
from order_table

The output header of this spooled data will be
item||'|'||ord_no||'|'||price||'|'|
--------------------------------
F42777|073059|100|


However now i want the header to be like this and the output remains the same....is there a way to do it?

item|ord_no|price|
--------------------------------
F42777|073059|100|

thanks for great help! Smilie Smilie
# 2  
Old 12-02-2005
You have to explicitly spool the contents of the header also like this.

Code:
spool $text;
select 'item|ord_no|price|' from dual;
select
item || '|' ||
ord_no || '|' ||
price || '|' ||
from order_table;
spool off

# 3  
Old 12-02-2005
Quote:
Originally Posted by mona
You have to explicitly spool the contents of the header also like this.

Code:
spool $text;
select 'item|ord_no|price|' from dual;
select
item || '|' ||
ord_no || '|' ||
price || '|' ||
from order_table;
spool off

i tried..but its not working..i get this
'item|ord_no|price|
-------------------
item|ord_no|price|

item || '|' ||ord_no || '|' ||price || '|' ||
---------------------------------------
F42777|073059|100|


now i have 3 header...... Smilie
# 4  
Old 12-02-2005
No '|' in alias

The '|' is the concatenation character in SQL. Hence it cannot be used in an alias name. Otherwise you could have given your column name an alias. Try reteivbg the column names in your script through another query and then merge the header and the data.

Regards,
Rahul.
# 5  
Old 12-02-2005
ok thanks! i got it..

Last edited by forevercalz; 12-02-2005 at 03:27 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. Shell Programming and Scripting

Manipulate all rows except header, but header should be output as well

Hello There... I have a sample input file .. number:department:amount 125:Market:125.23 126:Hardware store:434.95 127:Video store:7.45 128:Book store:14.32 129:Gasolline:16.10 I will be doing some manipulations on all the records except the header, but the header should always be... (2 Replies)
Discussion started by: juzz4fun
2 Replies

3. Shell Programming and Scripting

Add column header and row header

Hi, I have an input like this 1 2 3 4 2 3 4 5 4 5 6 7 I would like to count the no. of columns and print a header with a prefix "Col". I would also like to count the no. of rows and print as first column with each line number with a prefix "Row" So, my output would be ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. Shell Programming and Scripting

getting sql header from the script

i have the SQL as mentioned below. i put this sql in a file and calling from the script and output of SQL has been redirected to a file. but when i open the sql output file i dont see the header in sql output. how can i get the header also ? ==== SELECT RATE_CODE,NAME, CTR,TYPE ... (1 Reply)
Discussion started by: mail2sant
1 Replies

5. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

6. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

7. Shell Programming and Scripting

Need SQL output without the header.

Hi, In a script i am trying to run a SQL by connecting Sybase DB. While executing the script I am getting the output with the header. means: Employee_Name--------------------------- Anup Das I need the Output: Anup Das Kindly advice. (2 Replies)
Discussion started by: anupdas
2 Replies

8. Shell Programming and Scripting

Renaming all header to specific header pattern

Input #HAC0253 EFVHIJHIJEFVTHIJOPKOPKTEFVEFVEFVOPKHIJOPKOPKHIJTTEFVEFVTEFV #BASFS12 EFVEFVHIJEFVEFVTOPKEFVOPKTHIJTTHIJOPK #ACG5115 TEFVEFVOIJEFVHIJHIJOPKOPKHIJHIJTTEFVEFVOPKTTEFVEFVOPKHIJOPKOPKOPK #ECG5114 IJTOPKHIJEFVOEFVEFVOPKTTEFVEFVOPKHIJOPKOPKOPK . . Output (5 Replies)
Discussion started by: patrick87
5 Replies

9. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies
Login or Register to Ask a Question