Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Combine Unix variable with Oracle variable
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,
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
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