Variable not found error for a variable which is returned from stored procedure


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Variable not found error for a variable which is returned from stored procedure
# 1  
Old 03-17-2011
Variable not found error for a variable which is returned from stored procedure

can anyone please help me with this:

i have written a shell script and a stored procedure which has one OUT parameter. now i want to use that out parameter as an input to the unix script but i am getting an error as variable not found. below are the unix scripts and stored procedure...

-----------------------------------------------------
Code:
#!/bin/ksh
. /users/lrep/set10.2.0
 
export ORACLE_SID=SID123
var = `sqlplus –s login/password<<ENDOFSQL
set feedback off
exec NEW_PACKAGE.NEW_PROC;
exit;
ENDOFSQL`
 
echo $var

-------------------------------------------------------------
Code:
create or replace PROCEDURE NEW_PROC IS
 
cnt number(10) output
 
begin
select cnt = count(*) from emp;
 
end NEW_PROC;

----------------------------------------------------


Error: "var: not found"

----------------------------------------------------

Last edited by pludi; 03-17-2011 at 08:22 AM..
# 2  
Old 03-17-2011
Can you strip off the spaces around the equal to sign and try..
Code:
var=`sqlplus -s l...
..

# 3  
Old 03-18-2011
After trying with what you said... now I am getting a below error...

Error at line 1 ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in all to ‘NEW_PROC' ORA-06550: line 1, column 7: PL/SQL: Statement ignored

can you please help me in this?

---------- Post updated at 12:51 PM ---------- Previous update was at 12:41 PM ----------

Please note I had changed the stored procedure as below:


create or replace NEW_PROC (cnt out number) is

declare cnt int

begin

set cnt = (select count(*) from table)

end;

---------- Post updated at 04:11 PM ---------- Previous update was at 12:51 PM ----------

can anyone please help in resolving the problem i have posted??
# 4  
Old 03-18-2011
As you would know the error is related to Oracle. Please check the procedure you have written, it has some syntax errors. Or explain what your trying to achieve with the procedure. If your trying to read the row count of a table to a unix shell variable then try/compile either of the below procedures..
Code:
create or replace NEW_PROC is
begin
select count(*) from table;
end;

or

create or replace NEW_PROC is
cnt int;
begin
select count(*) into cnt from table;
dbms_output.put_line(cnt);
end;


Last edited by michaelrozar17; 03-18-2011 at 08:33 AM.. Reason: typo
This User Gave Thanks to michaelrozar17 For This Post:
# 5  
Old 03-22-2011
thanks it workedSmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Variable not found error in while loop

I am unable to use the value of a variable. while ] do LstFldDataPart =`head -n "$LstFldDataPartCntr" "${FeedFileDir}/${FeedFileBadRecs}" | tail -1 | tr -d '\n'` echo $LstFldDataPart JndLstFldDataPart="${JndLstFldDataPart}${LstFldDataPart}" LstFldDataPartCntr=... (3 Replies)
Discussion started by: TomG
3 Replies

2. Shell Programming and Scripting

Getting value of variable whose name is stored in another variable

Unix OS : Linux 2.6x Shell type : Korn I am stuck in weird problem . In my shell script I am setting an environment variable using the following command : EMP="KUMARJIT"; export EMP In the following sections of the script , what I did is : I created and initialized a new shell variable "type"... (5 Replies)
Discussion started by: kumarjt
5 Replies

3. UNIX for Dummies Questions & Answers

Variable not found error

Hi, I get a "FILEPATH: not found" error on the 3rd line and the line where it is within the case. Any idea as to why I'm getting this error time and time again? Oh and FILEPATH will store the directory of the file. I appreciate any help! IAM=`basename $0` RC=0 FILEPATH = ""... (1 Reply)
Discussion started by: MIA651
1 Replies

4. Shell Programming and Scripting

check variable value when nothing is returned

Hi all, I am wondering how can I check when a variable has nothing returned in it. I am trying to store a pid in this variable to see if a script is running in the background. So I am using something like that proc_pid=`ps -ef |grep script.sh|grep -v grep|awk '{print $2}'` if then ... (1 Reply)
Discussion started by: geovas
1 Replies

5. UNIX for Dummies Questions & Answers

Assigning the output of a command to a variable, where there may be >1 line returned?

Hello I am using unix CLI commands for the Synergy CM software. The command basically searches for a folder ID and returns the names of the projects the folder sits in. The result is assigned to a variable: FIND_USE=`ccm folder -fu -u -f "%name"-"%version" ${FOLDER_ID}` When the command... (6 Replies)
Discussion started by: Glyn_Mo
6 Replies

6. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

7. UNIX for Dummies Questions & Answers

Loop on array variable returning error: 0 not found

I'm guessing i have a syntax error. I'm not sure it get's past the the while condition. I get an error 0 not found. Simple loop not sure what I'm doing wrong. #!/usr/bin/ksh set -A MtPtArray /u03 /u06 tUbound=${#MtPtArray } echo $tUbound i=0 while ($i -lt $tUbound) do print... (4 Replies)
Discussion started by: KME
4 Replies

8. Shell Programming and Scripting

How to assign value to a variable with row(using -n) returned by sed

Hi Friends, REQUIREMENT: Want to delete files from the current directory match with the same in the file test.txt set -x i=1 echo "i=$i" COUNT=`sed -n '$=' test.txt` echo "Count=$COUNT" while do "## Here is error##" FILETOREMOVE=`sed -n \'$i,1p\' test.txt` echo $FILETOREMOVE... (5 Replies)
Discussion started by: sourabhsharma
5 Replies

9. Shell Programming and Scripting

script or piece of code where the data returned by a stored procedure you are writing

hi fndz. Can you please help me with the code if I call a stored procedure from my shell script and stored procedure returns a cursor, cursor output should be saved to a file (3 Replies)
Discussion started by: enigma_83
3 Replies

10. Shell Programming and Scripting

Assign the returned value of a function to a variable

Hi, Can anyone please show me how to assign the returned value of a function to a variable? Thanks. (2 Replies)
Discussion started by: trivektor
2 Replies
Login or Register to Ask a Question