Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

Question and Answer

Connor McDonald

Thanks for the question, Kalyana.

Asked: May 24, 2017 - 4:51 pm UTC

Last updated: May 26, 2017 - 1:19 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Dear Team,
Is it possible to have a script in sql and called in unix.

update table <
set col1= val1,
col2=val2
where <condition>

insert into table2
<>

Declare
<variable1>,
<variable2>
cursor <>

Begin

-- logic ---

exception

end;
/

Can the same be called in unix.

Thanks in advance !!

and Connor said...

Yes, but PLSQL must be called from a connected session to the database.

So from Unix you would (for example) have a shell script that would launch sqlplus, which would connect to the database and then run the routine, eg

#!/bin/ksh
print
"connect uname/pass@db
 exec my_proc
 exit" | sqlplus /nolog

Rating

  (1 rating)

We're not taking comments currently, so please try again later if you want to add a comment.

Comments

Calling PL/SQL from unix

Mark Adamson, May 25, 2017 - 2:09 pm UTC

While the example works it possibly exposes the password to the ps command. I would recommend

#!/bin/ksh

sqlplus /NOLOG <<EOSQL

connect uname/pass@db
exec my_proc
exit
EOSQL

Connor McDonald
May 26, 2017 - 1:19 am UTC

"it possibly exposes the password to the ps command"

How ?

There is no user/pass on the command line in my example.