Re: spool command in sql plus

From: gazzag <gareth_at_jamms.org>
Date: Thu, 1 Jul 2010 02:31:24 -0700 (PDT)
Message-ID: <cb674eca-8744-4ade-aa9c-cec1dab666e1_at_e5g2000yqn.googlegroups.com>



On 30 June, 16:22, dba cjb <chris.br..._at_providentinsurance.co.uk> wrote:
> I would like to pass a variable into a spool command so that a
> different report is created depending on the time of the create
>
> The pseudo code would be
>
> _at_1=name ||  || to_char ( date etc )
>
> spool _at_1
>
> Does anyone know how I can achieve this using pl/sql & or substition
> variables
>
> My aim is to timestamp the name of my reports
>
> regards
> Chris B

The SPOOL command is a SQL*Plus command, not a SQL one. I would set an environment variable at OS level and the shell will expand this correctly within your SQL script. For example, on a UNIX system, one could do:

$ export LOG_FILE=script_name_`date +"%d%m%y"`

Then, in SQL*Plus:

SQL> SPOOL $LOG_FILE etc...

HTH
-g Received on Thu Jul 01 2010 - 04:31:24 CDT

Original text of this message