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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How do you pass a value from a shell script into a sqlplus script?

Re: How do you pass a value from a shell script into a sqlplus script?

From: Martin Doherty <martin.doherty_at_oracle.comX>
Date: Mon, 21 Oct 2002 11:10:46 -0700
Message-ID: <KvXs9.6$kx5.52@news.oracle.com>


True, &1 &2 &3 etc. is the way to get the command line parameters into the sqlplus script, but if your script is anything other than trivial I'd recommend defining substitution variables with MEANINGFUL names, copy the parameters into them, and then only use the named variables throughout your script. Very difficult to work on a long script which is littered with numeric parameter names.
e.g.

DEFINE P_USER_NAME = "&1"
DEFINE P_START_DATE = "&2"
DEFINE P_DATE_FORMAT = "&3"

...
SELECT *
FROM PN_LEASE_MILESTONES_ALL
WHERE CREATED_BY = '&P_USER_NAME'
AND COMMENCEMENT_DATE = TO_DATE('&P_START_DATE', '&P_DATE_FORMAT') Those who follow in your footsteps will call upon all known gods to bless your name for eternity.

Martin

isa wrote:

>Hi:
>
>In the shell script: @fichero.sql PARAM1 PARAM2 PARAM3
>
>In the sql: where field1 = '&1' and field2 = '&2' and field3 = &3
>
>where parameters 1 and 2 are character and the 3 is numeric.
>
>Regards,
> Isa
>
>"Mike J" <mjjwestford_at_hotmail.com> escribió en el mensaje
>news:ur885v82jtbt45_at_corp.supernews.com...
>
>
>>I gather parameter values in a korn shell script and want to use them in a
>>sqlplus script that is called from the shell script. How do you pass a
>>
>>
>value
>
>
>>into the sqlplus script?
>>
>>
>>
>>
>
>
>
>
Received on Mon Oct 21 2002 - 13:10:46 CDT

Original text of this message

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