• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieving value from SQL Server 2000 stored procedure

 
as chhipa
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every body
I want to execute an query in stored procedure and after some calculation I want to retrieve some value which is specified by variable i in the follwing stored procedure.

CREATE procedure spTemp
@i as int OUTPUT
as
--select * from customer
......
......
......
select @i=3;
GO


Follwing is the code snippet for retrieving values from stored procedure
CallableStatement cs=conn.prepareCall("{call temp1(?)}");
cs.registerOutParameter(1,Types.INTEGER);
cs.execute();
int j=cs.getInt(1);
System.out.println("i="+j);


If I do not execute the query I get the correct value of i that is 3 but if I execute the query I get 0 as the value.
Can any body suggest why is it so and how can I execute the query and retrieve the values at the same time

Thank You.
 
Dan Howard
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use

and then look at the result set for the return value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic