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! :o :o
mona
December 2, 2005, 12:36am
2
You have to explicitly spool the contents of the header also like this.
spool $text;
select 'item|ord_no|price|' from dual;
select
item || '|' ||
ord_no || '|' ||
price || '|' ||
from order_table;
spool off
mona:
You have to explicitly spool the contents of the header also like this.
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......
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.