I am trying to write a unix program, in which I need to connect to the SQL DB and fetch the data and store it into a file.
Currently I am using the following command:
output1=`sqlplus -s username@SID/password <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING ON ECHO OFF;
SPOOL EMP_NAMES.txt
select emp_name from employee order by emp_name;
Spool off;
This is working fine. But my requirement was that I want to pass the value of spool file such that everytime a new Spool file would be generated.
I basically want to append the date at the end of the file name like:
date=`date +'%d/%m/%Y_%H:%M:%S:%2N'`
output1=`sqlplus -s username@SID/password <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING ON ECHO OFF;
SPOOL EMP_NAMES_$date.txt
Kindly let me know as to how this can be done.