just my 2p worth...
if you used a quality tool like sqlplus then you can just use the prompt keyword. so you just go:
spool my_file.txt
prompt this is my header
select * from dual --or whatever your query is
/
prompt this is my footer
spool off
just remember that union will implicitly group and order whereas union all will not. if you post something like this at forums.oracle.com in the sql / pl/sql forum you will get loads of responses from loads of know it alls... oh, and the difference will be that it will work, unlike alot of the guff above (although it did work in the end)!
if you used a quality tool like sqlplus then you can just use the prompt keyword. so you just go:
spool my_file.txt
prompt this is my header
select * from dual --or whatever your query is
/
prompt this is my footer
spool off
just remember that union will implicitly group and order whereas union all will not. if you post something like this at forums.oracle.com in the sql / pl/sql forum you will get loads of responses from loads of know it alls... oh, and the difference will be that it will work, unlike alot of the guff above (although it did work in the end)!
Comment