Re: Dynamic variables within unix script file...

From: Carsten Kristensen <ckr_at_ocsbrg.no>
Date: 7 Jan 1994 15:26:22 -0800
Message-ID: <2gkr2u$gmh_at_Jupiter.sco.com>


rutkowski_at_force.ssd.lmsc.lockheed.com writes:

>Can somebody help me!!!!
 

>I'm trying to pass a variable into a unix script to be used as a
>selection critira in a oracale SELECT statement and I'm not sure
>how to do this. My script file look like this:
 

> ***************************
 

>sqlplus login/password << end_select
 

>select * from table_name where emp_num = 21;
 

>end_select
 

> ****************************
>This script works and displays the employee information for the
>employee with employee_number = 21 but how can I make 21 a dynamic
>variable so I can run this from a unix prompt and pass in a value?
 

>$ script_name 21
>$ script_name 101
> .
> .
> .

Hello!
Simply changing the line containing your select statement to:

select * from table_name where emp_num = $1;

should do the trick. The Unix shell will substitute the $1 with the first parameter you give in, before passing the command to SQL*Plus.

Regards,

--
| Carsten Kristensen		| E-mail: ckr_at_ocsbrg.no 	|
| Offshore Computer Services AS | Tel   : +47 55 99 88 70	|
| Bergen, Norway		| Fax   : +47 55 99 88 84	|
| select std_disclaimer from opinions_not_shared_by_employer;   |
 =================================================================
Received on Sat Jan 08 1994 - 00:26:22 CET

Original text of this message