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: Combine Unix variable with Oracle variable

Re: Combine Unix variable with Oracle variable

From: <Kenneth>
Date: Thu, 15 Jun 2006 18:37:22 GMT
Message-ID: <4491a42f.16253468@news.inet.tele.dk>


On 15 Jun 2006 10:06:25 -0700, "aman.oracle.dba" <aman.oracle.dba_at_gmail.com> wrote:

>Hello DBAs,
>
>Please tell how to send any bind variable value to unix variable.
>Example
>in unix
>
>$a=10
>$sqlplus "/ as sysdba"
>sql>variable b number:=10;
>
>Now I want to compare b and a in shell scripting and in one pl code
>also but how is it possible.Please help..........
>
>Thank You
>

Hi there,

  1. Passing parameters from shell script to sql*plus :

parameter1=20
parameter2=30
sqlplus user/pw_at_db @myscript.sql $parameter1 $parameter2

and myscript.sql receives the parameters via the default prefix '&' (can be changed) :

myscript.sql



set serveroutput on;  

begin
 if '&1' = '&2' then
   dbms_output.put_line('They matched');  else
   dbms_output.put_line('They did not match');  end if;
end;
/
exit;


2) Passing parameter from sql*plus to shell script :

set serveroutput on;
define parm1=4
define parm2=5
host myscript.sh &parm1 &parm2

Received on Thu Jun 15 2006 - 13:37:22 CDT

Original text of this message

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