加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sqlserver 存储过程 返回多个select 结果集

发布时间:2020-12-12 13:16:10 所属栏目:MsSql教程 来源:网络整理
导读:sql server 数据库的存储过程 ? ALTER PROCEDURE?[prc_******]? ??? @obligateFour Varchar(50), ??? @obligateFive Varchar(50) AS BEGIN select? * from? a select * from? b end ? ? java jdbc 调用方法: ?? public String getInsureDetail(String obliga

sql server 数据库的存储过程

?

ALTER PROCEDURE?[prc_******]?
??? @obligateFour Varchar(50),
??? @obligateFive Varchar(50)
AS
BEGIN

select? * from? a

select * from? b

end

?

?

java jdbc 调用方法:

?? public String getInsureDetail(String obligateFour,String obligateFive) throws UnsupportedEncodingException,Exception {
??????? Connection conn = null;
??????? ResultSet rs1 = null;
??????? ResultSet rs = null;
??????? CallableStatement proc = null;

??? try{

?????????? conn = new MSConnection().getConnection();
?????????
??????????? proc = conn.prepareCall("{call prc_bzdbbx_getinsuredetail(?,?)}");
??????????? proc.setString(1,obligateFour);
??????????? proc.setString(2,obligateFive);
??????????? rs1=proc.executeQuery();

????????????while ?(rs1!=null&&rs1.next()){

????????????? .............

?????????????}

????????? .................

?????????proc.getMoreResults();???????
??????? ?rs= proc.getResultSet();

?? ?????while(rs!=null&&rs.next()) {

?????? ??? ....................

??????? }

??? }catch (Exception e) { ??????????? e.printStackTrace(); ??????????? throw new Exception(ChangeCode.utf8ToBase64(e.getMessage())); ??????? } finally { ??????????? try { ??????????????? if (rs1 != null) { ??????????????????? rs1.close(); ??????????????? }??????????? ? ??????????????? if (rs != null) { ??????????????????? rs.close(); ??????????????? } ??????????????? if (proc != null) { ??????????????? ?proc.close(); ??????????????? } ??????????????? if (conn != null) ??????????????????? conn.close(); ??????????? } catch (SQLException e) { ??????????????? e.printStackTrace(); ??????????? } ??????? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读