Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Spooling SQL*Plus output to a unique file name (Unix)
Hi
You can use UTL_FILE in append mode.
Jack
"Patricia Clarke" <pclarke_at_mach2.wlu.ca>@fatcity.com on 05/02/2000 12:33:30 AM
Please respond to ORACLE-L_at_fatcity.com
Sent by: root_at_fatcity.com
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
cc:
Subject: Spooling SQL*Plus output to a unique file name (Unix)
Oracle 7.3.4, Dynix 4.2.3, SQL*Plus 3.3.4, PL/SQL 2.3.4
I have a PL/SQL script that I am running on the server (Unix) and I am spooling the output into a log file. The problem is that I don't want to lose the previous output each time I run the script, so I want to be able to either spool to a unique file name each time (e.g. by appending a timestamp or the process ID or something to the log file name), or keep the same file name but *append* the new output to the old instead of overwriting everything each time.
I have read the SQL*Plus documentation on the SPOOL command and don't see any options for appending output to an existing file instead of overwriting, so I'm guessing that's not possible...
So, I guess I am looking to do something like:
DECLARE unique_file_name VARCHAR2(18);
...
BEGIN
...
SELECT to_char(sysdate,'YYYYMMDDHHMISS')||'.log'
INTO unique_file_name
FROM dual;
...
SPOOL unique_file_name
...
SPOOL OFF
END;
But, this doesn't work because Oracle doesn't like the SPOOL statements
within the PL/SQL block, but if I take them out of the PL/SQL block, I get a
log file called unique_file_name.lst rather than 20000501103013.log (or
whatever).
I'm probably missing something stupid here, but can't seem to get any further...
Thanks very much for any ideas,
Patricia
-- Author: Patricia Clarke INET: pclarke_at_mach2.wlu.ca Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). =================================================================== De informatie verzonden met dit E-mail bericht is uitsluitend bestemd voor de geadresseerde. Gebruik van deze informatie door anderen dan de geadresseerde is verboden. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking van deze informatie aan derden is niet toegestaan. Ernst & Young staat niet in voor de juiste en volledige overbrenging van de inhoud van een verzonden E-mail, noch voor tijdige ontvangst daarvan. =================================================================== The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. Ernst & Young is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in itsReceived on Tue May 02 2000 - 02:37:46 CDT
![]() |
![]() |