日期:2014-05-17  浏览次数:20816 次

请教如何查询临时表返回到resultset
Java code
 

sqlstr="select no=Identity(int,1,1), col1,col2 Into #temptable  "
      +" from table1  ";

PreparedStatement stmt = conn.prepareCall(sqlstr,
    ResultSet.TYPE_SCROLL_INSENSITIVE,        
    ResultSet.CONCUR_UPDATABLE);

stmt.execute();

sqlstr=" Select * From #temptable where no>10 ;";

ResultSet rs = stmt.executeQuery();




我这样做 无法获取查询到数据返回记录集 请问给位应该如何做呢

------解决方案--------------------
stmt是同一个?
sqlstr=" Select * From #temptable where no>10 ;"
stmt = conn.prepareCall(sqlstr,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery();试试
------解决方案--------------------
qlstr=" Select * From #temptable where no>10 ;"
stmt = conn.prepareStatement(sqlstr);
ResultSet rs = stmt.executeQuery()
------解决方案--------------------
探讨
Java code


sqlstr="select no=Identity(int,1,1), col1,col2 Into #temptable "
+" from table1 ";

PreparedStatement stmt = conn.prepareCall(sqlstr,
ResultSet.TYPE_SCROLL_INSENSITIVE,……

------解决方案--------------------
不明白啥意思,在stmt.execute()加个断点,执行后判断临时表是否有数据