Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: using SPOOL in sqlplus
froliol_at_my-deja.com wrote:
> Greetings All, I want to be able to create a dynamic output file name
> based on current date and time. Using spool I cannot seem to pass a
> name for an output file, I can only explicitly state it? Has anyone
> ever passed a variable name to spool as the output file?
>
> Any help would be greatly appreciated.
>
> L
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
If you are on a unix platform, try the following -- Step 1 - create your sql script (say spool_file_w_timestamp.sql) like:
spool <yourfilename>.&1
<your sql statement>;
spool off
exit
Step 2 - run the following command at the shell prompt:
sqlplus -s <youroraclelogon>/<yourlogonpassword>@<yoursid> @spool_file_w_timestamp `date -u +"%Y%m%d%H%m"`
A spool file named <yourfilename>.<timestamp> will be created. Here <timestamp> will in the format as yyyymmddhhmi.
Hope this helps.
Shana Chen at schen_at_cnri.reston.va.us Received on Tue Oct 03 2000 - 17:09:22 CDT