Link to home
Start Free TrialLog in
Avatar of the_7th_king
the_7th_kingFlag for India

asked on

Accessing temp table result set through JDBC

Hello,

I have written a procedure in MS SQL. In this procedure, I've created a temp table and put data inside this table.

I do a select * from this temp table and then drop the table.

Now, I want to access this result set in JDBC, but it gives me an error "Statement does not return any result set". If I run the procedure from within SQL itself, the result set comes up fine.

Please suggest.
Avatar of DcpKing
DcpKing
Flag of United States of America image

If it's a temp table named with a # then it should go away on its own when your connection drops, so just don't delete it. OTOH, if you're going to call the proc repeatedly you should check if it exists and kill it if it does, and then recreate it and use it.

You might also look at using Table Vars instead of temp tables - they go away automagically after you leave the proc.

If you still don't get any results according to JDBC then please post your code.
Avatar of the_7th_king

ASKER

Even if I stop manually dropping the temp tables, the result set still cannot be displayed in JDBC
Well, it's 12 years since I used JDBC, and it had some wild bugs then! Anyhow, check this out.  There's an answer from a guy who upgraded from SS2000 to SS2005 and it stopped giving him back an answer maybe that'll help you!

hth

Mike
ASKER CERTIFIED SOLUTION
Avatar of DcpKing
DcpKing
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Perkins
I have written a procedure in MS SQL. In this procedure, I've created a temp table and put data inside this table.
Post your code.
putting a "NO COUNT" did the trick!

thanks a lot!