I have a stored procedure which returns multiple result sets as follows,
create proc test as
begin
select '1'
select a,b into #temp from TABLE1
select * from #temp
select '2'
select 'Done'
end
And my java call is,
CallableStatement stmt = null;
String procString= "EXEC test";
stmt = conn.prepareCall(procString);
boolean results = stmt.execute();
System.out.println(results);
do {
if(results) {
rs = stmt.getResultSet();
while (rs.next()) {
System.out.println(rs.getString(1) + ", " );
}
rs.close();
}
System.out.println();
results = stmt.getMoreResults();
System.out.println("results - "+results);
} while(results);
So as per the above snippet, the output should have all the 4 selects. But I just get the first select and nothing else. I just removed the second select which does insert into temp table, after which I get all the 4 selects.
Why does this happen?