The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reading the header of a tar file(posix header) Tanvirk Linux 2 01-31-2008 05:50 AM
insert header row into .xls Tish UNIX for Dummies Questions & Answers 11 12-07-2007 12:53 PM
How to Parse TCP header cool_vip High Level Programming 2 08-23-2005 05:27 AM
Creating a header. rooh UNIX for Dummies Questions & Answers 2 04-06-2002 02:41 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-01-2005
Registered User
 

Join Date: Sep 2005
Posts: 74
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!
Reply With Quote
Forum Sponsor
  #2  
Old 12-01-2005
mona's Avatar
Registered User
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
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
Reply With Quote
  #3  
Old 12-01-2005
Registered User
 

Join Date: Sep 2005
Posts: 74
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......
Reply With Quote
  #4  
Old 12-01-2005
Registered User
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 156
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.
Reply With Quote
  #5  
Old 12-02-2005
Registered User
 

Join Date: Sep 2005
Posts: 74
ok thanks! i got it..

Last edited by forevercalz; 12-02-2005 at 12:27 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0