当前位置: 代码迷 >> Java Web开发 >> 请问怎么查询临时表返回到resultset
  详细解决方案

请问怎么查询临时表返回到resultset

热度:5321   发布时间:2013-02-25 21:09:44.0
请教如何查询临时表返回到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()加个断点,执行后判断临时表是否有数据
  相关解决方案