Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How2 Generate current date in spool-filename in SQL+
mlouwes_at_yahoo.com wrote in message news:<41434413.0301150351.1640818e_at_posting.google.com>...
> I use sql+ and I want the results of my query in a spool file.
> I need to run this query everyday from the Scheduler and want a new
> file everyday, so I need to generate a unique filename in sql+
> preferable with the current date in the name of the file.
> How can I do this ??
>
> Thanks for your help
>
> Marcel
You have an option to use either UTL_FILE package. Some sample code
located at,
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&selm=92eeeff0.0301131613.6c284a00%40posting.google.com&rnum=2
OR
Pass constructed filename as command line parameter to your sql file. e.g.
Sqlfile.sql
connect xxxx/xxxxx_at_xxxxx
spool C:\YourSpoolDir\&1
select ....
spool off
exit
Construct your date e.g. on Win2K you can do something like,
C:\> FOR /F "tokens=1-3 delims= " %%A in ("%date%_%time%") do set
time_stamp=%%B%%C
C:\> FOR /F "tokens=1-3 delims=/" %%A in ("%time_stamp%") do set
time_stamp=%%A%%B%%C
C:\> FOR /F "tokens=1-3 delims=:" %%A in ("%time_stamp%") do set
time_stamp=%%A%%B%%C
C:\> FOR /F "tokens=1-2 delims=." %%A in ("%time_stamp%") do set
time_stamp=%%A%%B
C:\> sqlplus @Sqlfile.sql %time_stamp%.spl
Regards
/Rauf Sarwar
Received on Wed Jan 15 2003 - 11:34:21 CST