Quantcast
Channel: EasyOraDBA
Viewing all articles
Browse latest Browse all 263

Generate Excel | CSV Report from SQL*PLUS

$
0
0

Shell Script to generate a column seperator report in SQL*PLUS using a shell script. It can be opened in Excel and or text editor like NOTEPAD++

 

#!/bin/ksh
. $HOME/.bash_profile
NOW=$(date +”%a %b %e %T %Y”)
HOST=$(hostname)
MON2=$(date +”%b%Y”)

cd $HOME/scripts
rm -rf Report_$MON2.csv

sqlplus -s /NOLOG << EOF > /tmp/log.txt
CONNECT abc/*****

set colsep ;
set pagesize 1000
set trimspool on
set headsep off
set linesize 9999

alter session set nls_date_format = ‘DD/MM/YYYY’;
spool Report_$MON2.csv
select * from tablename where condition;
spool off
exit
EOF



Viewing all articles
Browse latest Browse all 263

Trending Articles