I have a requirement to create a temp table and select on the temp table against Netezza DB in one session.
Tables: abc, def
String query = create temp table MyTemp as select * from abc join def; select col1, col2 from MyTemp;";
boolean result = statement.execute(query);
while(true) {
if(result) {
ResultSet rs = statements.getResultSet();
while(rs.next()) {
//Access result set.
}
} else {
int count = statement.getUpdateCount(); -- CREATE statement output
if(count == -1) {
break;
}
result = statement.getMoreResults();
}
}
I expected to get the updatecount and then a resultset from the statement as I am executing CREATE temp statement followed by SELECT statement.
I get result as true for the first statement(CREATE statement output). But later when statement.getMoreResults gets executed I get false. But according to documentation the statement.getMoreResults returns true for ResultSet output.
I have an alternative solution of splitting the string using semicolon and executing the individual queries using the same statement. But I want to know why the above solution doesn't work.