Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Combine Unix variable with Oracle variable
aman.oracle.dba 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
#!/bin/ksh
a=10
sqlplus /nolog <<EOF
connect user/passw
set serveroutput on size 1000000
declare
a number:=$a; b number:=10;
dbms_output.put_line('Wow!!! They match!!!'); else
dbms_output.put_line('Darn!! They don''t match!!');
end if;
end;
/
EOF
To allow input to the shell script:
#!/bin/ksh
if [ $# -eq 0 ]
then
echo "Usage: `basename $0` value" echo "where value is a number of your choice" exit 2
sqlplus /nolog <<EOF
connect user/pass
set serveroutput on size 1000000
declare
a number:=$1; b number:=10;
dbms_output.put_line('Wow!!! They match!!!'); else
dbms_output.put_line('Darn!! They don''t match!!');
end if;
end;
/
EOF
If that isn't what you had in mind then be more specific with your
questions.
David Fitzjarrell Received on Thu Jun 15 2006 - 12:34:09 CDT
![]() |
![]() |