Re: SqlPlus: dynamic name for a spool file

From: Mladen Gogala <gogala.mladen_at_gmail.com>
Date: Wed, 18 Apr 2012 19:46:18 +0000 (UTC)
Message-ID: <jmn5ma$cab$1_at_solani.org>



On Wed, 18 Apr 2012 17:06:53 +0200, Michel Cadot wrote:

> "Maikku" <kangasmaki_at_netti.fi> a écrit dans le message de news:
> 2144735.1356.1334755734839.JavaMail.geo-discussion-forums_at_vbuo5...
> | Why is this working:
> | ACCEPT TESTNUMER NUMBER PROMPT "GIVE A NUMBER> "
> |
> | SPOOL &TESTNUMBER._LOGNAME.LOG |
> | but this isn't:
> | SPOOL LOGNAME_&TESTNUMBER..LOG |
> | It seems, that I can use a number in logname if it's in the beginning
> of the logname, but otherwise not. If I use char it works both ways.
> |
> | I'm using SqlPlus 10.2.0.2.
> |
> | TIA |
> | Maija-Leena
>
> Just execute "DEF TESTNUMBER" and you will understand.
> If you don't then execute "PROMPT LOGNAME_&TESTNUMBER..LOG" and I hope
> this time you will.
>
> Regards Michel

Sorry, no dynamic spool names:

SQL> column mydt new_value mynum
SQL> select to_number(to_char(sysdate,'J')) as mydt from dual;

      MYDT


   2456036

Elapsed: 00:00:00.02
SQL> select &&mynum+1 from dual;
old 1: select &&mynum+1 from dual
new 1: select 2456036+1 from dual

 2456036+1


   2456037

Elapsed: 00:00:00.01
SQL> spool /tmp/test_&&mynum
SP2-0768: Illegal SPOOL command
Usage: SPOOL { <file> | OFF | OUT }
where <file> is file_name[.ext] [CRE[ATE]|REP[LACE]|APP[END]] SQL>   Oracle doesn't allow that. Of course, there are other scripting languages that can be used to that end.

-- 
http://mgogala.byethost5.com
Received on Wed Apr 18 2012 - 14:46:18 CDT

Original text of this message