Hi All,
I am trying to create a CSV file within a shell script test.ksh
and the code snippet is something like below:
#!/usr/bin/ksh
# Set required variables.
. $HOME/.prof
# Output file path
Group1=/tmp/G1.csv
Group2=/tmp/G2.csv
Group3=/tmp/G3.csv
$ORACLE_HOME/bin/sqlplus -s $UNAME << EOF
WHENEVER SQLERROR EXIT FAILURE
SET FEEDBACK OFF
SET ECHO OFF
SET VERIFY OFF
SET HEADING OFF
SET SERVEROUTPUT ON
SET TRIMSPOOL ON
SET PAGESIZE 0
SET NEWPAGE NONE
set linesize 10000
set pagesize 1000
set colsep ","
set trimspool on
SPOOL $Group1
select...
from...
where...
SPOOL OFF
EXIT
EOF
The same logic is followed for the other two files as well. But when the script is run, G1.csv
gets created but gives the following message for the other two:
./test.ksh
/tmp/G2.csv: No such file or directory
/tmp/G3.csv: No such file or directory
The second time when run, G2.csv
gets created but for the third file I get:
./test.ksh
/tmp/G3.csv: No such file or directory
Subsequent runs give the same message as above and G3.csv
doesn't get created at all.
Am not able to understand what's wrong here:confused: Any help would be greatly appreciated.