用游标做的分页存储过程,如何取出记录集呢

New_Nice 2007-06-28 10:08:49
我附上我的存储过程:数据库是MSSql
CREATE PROCEDURE infopagelist
@currentpage int,@keyword varchar(100)
as

SET NOCOUNT ON
Declare @p1 int,@rowcount int,@pagesize int,@sqlstr varchar(1000)
set @pagesize=40
set @sqlstr='select id,title from T_info'
if @keyword!='' begin
set @sqlstr=@sqlstr+' where title like ''%'+@keyword+'%'''
end
set @sqlstr=@sqlstr+' order by id desc'

exec sp_cursoropen @p1 output,@sqlstr,@scrollopt=1,@ccopt=1
--select ceiling(1.0*@rowcount/@pagesize) as totalpage
set @currentpage=(@currentpage-1)*@pagesize+1
exec sp_cursorfetch @p1,16,@currentpage,@pagesize
exec sp_cursorclose @p1
set nocount off
GO
如何取出记录集呢,我试两天了,也找了相关资料,一直没有成功,请求达大帮忙.
...全文
188 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengmingjie 2007-07-09
  • 打赏
  • 举报
回复
import java.sql.*;

public class Test Conn{

private Connection getConn(){
Connection conn = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
try {
conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&
characterEncoding=GBK","root","ntsky");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}

public void testC() {
Connection conn = getConn();
ResultSet rs = null;
CallableStatement cs = null;
String a = null;
try {
CallableStatement cStmt = conn.prepareCall("{call p_test()}");
cStmt.executeUpdate();
} catch (Exception e) {
System.out.println("hahad" + e.getMessage());
} finally {
try {
conn.close();
} catch (Exception ex) {
System.out.println("ex : " + ex.getMessage());
}
}

}

public static void main(String[] args) {
new TestConn().testC();
}
}

myydzhz 2007-07-09
  • 打赏
  • 举报
回复
create or replace procedure P_YJ_YJGL //数据库oracle
(
AS_YHM IN VARCHAR2, --用户名
AS_NSRSBH IN VARCHAR2, --纳税人识别号
AS_LX IN VARCHAR2, --类型
RC_GLJG OUT WEB_WSSB.PKG_TYPES.REF_CURSOR)
is
ac_msg varchar2(30);

begin
OPEN RC_GLJG FOR
SELECT ac_msg FROM DUAL; //得到记录集
end P_YJ_YJGL;
New_Nice 2007-07-09
  • 打赏
  • 举报
回复
没有人知道怎么调用嘛,请高手给些帮助

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧