Wednesday, 6 June 2012

sqlplus output to file with out display and trims on

http://blog.niklasottosson.com/?p=761

http://stackoverflow.com/questions/6813210/oracle-sqlplus-saving-output-in-a-file-but-dont-show-on-screen



SET echo off
02SET feedback off
03SET linesize 100
04SET pagesize 0
05SET sqlprompt ''
06SET trimspool on
07SPOOL filename.csv
08 
set Termout off
09SELECT field1 || ',' || field2 || ',' || field3 FROM tablename;
10 
11SPOOL off
12exit
st

1 comment:

  1. IF bymistake you have run the query..
    sed -e 's/\ \ *$//' filename >filename.txt

    ReplyDelete