Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pass variable from Shell script to plsql block

781163Jan 13 2012 — edited Apr 23 2012
Hi,
I am having a shell script and having to pass parameter from Shell script into a PLSQL block, I am using the below code but unable to fetch any result,
Can anyone help me sort this out??

Shell Script: test.sh


*#!/bin/sh*

var1=$1

SQLPLUS="sqlplus -s"
LOGON="gmisowner/gmisowner1"

day=`$SQLPLUS $LOGON <<++
set heading off
set feedback off

begin
select count() from mis_ref_codes where ref_description=&var1;*

end;

exit;
++`

echo $day

Execution at command prompt: > ./test.sh Underline
does not return anything

1. I was hoping the count(*) of the number of rows from the select statement will be stored in day, but nothing returns as an output from the plsql block
the above select statement is a sample but I am having to run a much bigger plsql block

Am I doing something wrong syntactically here? please suggest

Edited by: Hemz on Jan 14, 2012 12:35 AM
This post has been answered by Solomon Yakobson on Jan 13 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2012
Added on Jan 13 2012
10 comments
7,748 views