Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: spool file naming

Re: spool file naming

From: Suresh Bhat <suresh.bhat_at_mitchell-energy.com>
Date: Thu, 18 Nov 1999 16:40:06 GMT
Message-ID: <01bf31f3$f24538e0$a504fa80@mndnet>


Hi,

Below are two SQL scripts. Choose the one that suits you and modify.

REM

REM     Author     : Suresh N. Bhat
REM     Date       : 10/03/94
REM     File Name  : unix_dated_spool_name.sql
REM     Usage      : On sqlplus prompt enter:
REM                      @unix_dated_spool_name
REM     Description: Creates a variable file name from Unix date command
REM                  to which the output from sqlplus script is spooled.
REM
rem
rem create temporary file suresh.x
rem
spool $HOME/suresh.x
select sysdate from dual;
spool off
rem
rem create shell variable for the actual file name, such as spec_06.94; rem copy suresh.x to this file and force remove suresh.x rem
host BHAT=$HOME/`date +spec_%m.%y`; cp $HOME/suresh.x $BHAT; host rm -f $HOME/suresh.x
exit

REM

REM     Author     : Suresh N. Bhat
REM     DATE       : 10/03/94
REM     File Name  : sql_dated_spool_name.sql
REM     Usage      : On sqlplus prompt enter:
REM                     @sql_dated_spool_name
REM     Description: Creates a variable file name from Oracle date
functions
REM                  to which the output from SQL*Plus script is spooled.
REM
set heading off feedback off verify off pause off column year newline
rem
rem Create temporary file to define MONTH and YEAR variables. rem
spool suresh.sql
select 'define MONTH ='||lpad((to_char(sysdate,'mm')),2,'0'),

       'define YEAR ='||lpad((to_char(sysdate,'yy')),2,'0') year from dual;
spool off
set heading on feedback on verify on pause on rem

rem     Start the temporary file so that defines can be used in the
rem     spool command below.

rem
start suresh.sql
rem
rem     The first period(.) below signifies end of define MONTH variable.
rem     The second period(.) below is the dot(.) between the file name
rem     and its extention.

rem
spool spec_&MONTH..&YEAR
select sysdate from dual;
spool off
host rm suresh.sql
exit

Suresh Bhat
Oracleguru
www.oracleguru.net

kal121_at_yahoo.com wrote in article <80skjo$mdb$1_at_nnrp1.deja.com>...
> Is there an easy way to append the sysdate to the spool file name?
>
> SPOOL c:\myfolder\file||SYSDATE||.log -- sort of like this?
>
>
> Thanks!
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Received on Thu Nov 18 1999 - 10:40:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US