I have this UNIX script code with a query to export sql table in Oracle and export to csv file. The code gets the data correctly. However, when I run the script second time, I got the error message "not spooling currently" and shows the older data in csv file. When I delete the csv file and run the script it works again. I want the script to get me the recent data when I run it.
Do you know why?
FILE="NEW_FILE_TRANSFER.csv"
sqlplus -s xyz_dev/abc123@GEEE3 <<EOF
SET PAGESIZE 50000
SET COLSEP ","
SET LINESIZE 6500
SET FEEDBACK OFF
SET TRIMSPOOL ON
SPOOL $FILE
SELECT * FROM FILE_TRANSFER;
SPOOL OFF
EXIT
EOF
Thanks all for your replies.
I think I found the problem. Every time I try to see the csv output file, the sheets are open on my window and never tried to close it. When I close all the current sheets and run the script again, it works.
I will update more findings.
So each time you execute a script, it will generate a CSV file with current date up to second included.
If this is being executed in extremely high intervals, one may find various ways to generate 'randomness' to include in file name.
But for this and other things, you would need to include operating system details and shell used.
Please include those in this and future posts!