MySQL Forums
Forum List  »  Stored Procedures

how to return values from procedure??
Posted by: mahadev sawale
Date: September 09, 2006 03:01AM

hello all,
i have written one procedure which takes one parameter as in and returns other as out. this procedure works fine in mysql, where i have to call procedure as

mysql> call salproc(@ret); returned values will be in @ret variable.

But when i call it from java program, problem arises.
this my proc and java program.

create procedure salproc(in p int,out ret int)
declare s,b,i int;
declare cur cursor for select sal from test1 order by sal desc;
declare exit handler for not found begin end;
set s=0,b=0,i=0;
open cur;
fetch cur into s;
set i=i+1;
if i>=p then
leave label;
end if;
end loop;
close cur;
set ret=s;

//java program
int salary,x=0;
x=stmt.executeUpdate("call salproc(@"+salary+",10)");
rs=stmt.executeQuery("select @salary");;
catch(Exception e)

i want the returned value in salary variable.
can anybody help me to solve this prob.

Options: ReplyQuote

Written By
how to return values from procedure??
September 09, 2006 03:01AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.