Thursday, January 20, 2011

spool without trailing white spaces

Below set of sample code will generate a CSV report and the output file will not have any trailing extra white spaces:

sqlplus –s user@DBNAME
set echo off
set feedback off
set pagesize 0
set linesize 2000
set heading off
set trimspool on
spool test.csv
select 'check_list,status,ins_date' from dual;
select t.check_list||','||t.status||','||to_char(t.ins_date,'dd-Mon-yy hh24:mi:ss') from my_tab t;
spool off
exit

1 comment:

  1. Thanks Obaid vai. It should be used instead of UTL_FILE package for writing simple files outside stored procedure. It is simple to manage also. I have one request to you. Most of your posts do not have any verbosity. Please elaborate more.

    ReplyDelete