Hi,
I'm trying to declare and use temporary tables. I have written the
following code in Java. Creating the tablespace (i can see the
tablespace created using the Control Center), the temporary table and
even inserting the values execute fine (even the executeUpdate while
inserting returns a positive number indicating that rows have been
inserted). However, when I select * from the temporary table, 0 rows
are returned and the while loop is never entered. Any ideas why this is
happening?? Is it some configuration of my database?
Thanks in advance! Any help would be greatly appreciated... :)
==============================
import java.sql.*;
public class TempTableTest {
public static void main(String[] args) {
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").ne wInstance();
String machine = "jdbc:db2:pmi";
String userName = "db2admin";
String password = "somepassword";
Connection conn =
DriverManager.getConnection(machine,userName, password);
Statement stmt = conn.createStatement();
stmt.executeUpdate("CREATE USER TEMPORARY TABLESPACE usertemp1 " +
" MANAGED BY SYSTEM " + " USING ('usertemp')");
stmt.executeUpdate("DECLARE GLOBAL TEMPORARY TABLE temptb1 " +
" LIKE mantest_featsum " +
" NOT LOGGED " +
" IN usertemp1");
stmt.executeUpdate(
"INSERT INTO session.temptb1 " +
"(SELECT
slidebarcode,total,gp2count,gp3count,gp5count,gp7c ount,gp9count FROM
mantest_featsum)");
ResultSet rs = stmt.executeQuery("SELECT * FROM session.temptb1");
while (rs.next())//Fetch a row of data
{
rs.getInt(2);
}
stmt.close();
conn.close();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
}