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: Any trick for preventing sqlplus asking value for &1???

Re: Any trick for preventing sqlplus asking value for &1???

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Wed, 05 Mar 2003 17:57:21 GMT
Message-ID: <MPG.18cfda5ab6b85d729896e0@news.la.sbcglobal.net>


maxim99_at_libero.it said...
> Hi,
>
> I wrote a scritp which I execute from sqlplus in this way:
>
> @script.sql <parameter>
>
> In the script I use the parameter (&1).
>
> My question is:
> is it possibile to execute the script without passing the parameter
> and using some default value?
> Infact, I must execute the script with or without the parameter. In
> case I don't pass parameter I wouldn't want sqlplus asking for it.
>
> Tia
>
> Max
>

It's kinda convoluted, but maybe this is what you're looking for:

parent.sql



set define on
@@child ''
@@child 'param'

child.sql



prompt Arg=&1

variable b_arg1 varchar2(40)

set termout off
execute :b_arg1 := '&1'
set termout on

--print b_arg1

column source_arg new_value v_source_arg noprint select nvl( :b_arg1, 'default value') source_arg from dual;

prompt Source arg is: &&v_source_arg

-- 
/Karsten
DBA > retired > DBA
Received on Wed Mar 05 2003 - 11:57:21 CST

Original text of this message

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