Skip navigation links

MySQL Forums :: Stored Procedures :: how to return values from procedure??


Advanced Search

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)
begin
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;
label:loop
fetch cur into s;
set i=i+1;
if i>=p then
leave label;
end if;
end loop;
close cur;
set ret=s;
end

//java program
int salary,x=0;
x=stmt.executeUpdate("call salproc(@"+salary+",10)");
rs=stmt.executeQuery("select @salary");
rs.next();
System.out.println(salary);
System.out.println(rs.getInt(1));
}
catch(Exception e)
{
System.out.println(e);
}

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

Options: ReplyQuote


Subject Views Written By Posted
how to return values from procedure?? 2251 mahadev sawale 09/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.