I have a stored proc which creates multiple temp tables, then creates a join on the various temp tables.
If I execute the stored proc in MS SQL 2008 I am able to see the output of the resulting select clause. However when i call the stored proc via JDBC I keep getting an error saying the Statement did not return a result set.
I looked around a lot but couldn’t find a solution, so I resorted to creating a persistent table and inserting the output of the stored proc into it.
- Why does this happen? (I read something that said, as the temp table is truncated as soon as the stored proc finishes executing, no result set will get returned via JDBC)
- Is there a way to do this without using a persistent table?
This is a similar question :
Temporary tables using JDBC with null ResultSet
and this is the accepted answer : http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/67b10d74-e94f-4b58-8ee3-59ff390db1cf
Summary – for stored procedures returning from temporary tables, don’t use a PreparedStatement, use a regular Statement instead.