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: <fitzjarrell_at_cox.net>
Date: 15 Jun 2006 10:34:09 -0700
Message-ID: <1150392849.696434.145230@y41g2000cwy.googlegroups.com>

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;

begin
if a = b then

        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

fi

sqlplus /nolog <<EOF
connect user/pass
set serveroutput on size 1000000
declare

        a number:=$1;
        b number:=10;

begin
if a = b then

        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

Original text of this message

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