• mybatis获取存储过程返回结果


     获取存储过程返回结果

    代码:

    //  
    Map<String,Object> map = new HashMap<String,Object>(); map.put("id","11"); loginDao.login(map); //获取结果集 map.get("result_2"); map.get("resultbean"); //dao层 public void login(Map<String,Object> map);
    <resultMap id="loginMap" type="java.util.HashMap">
        <result  column = "SYS_ID"  property = "sysId"/>
        <result  column = "ROLE_ID"  property = "roleId"/>
        <result  column = "AUTH_ID"  property = "authId"/>
    </resultMap>
    
    
    <select id="login" resultType="java.util.Map" statementType="CALLABLE">
        <![CDATA[ 
        call proc_login(
                        #{id,mode=IN,jdbcType=VARCHAR},
                        #{result_2,mode=OUT,jdbcType=VARCHAR},
                        #{resultbean,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=loginMap})
        
        ]]>    
    </select>
    create or replace  procedure proc_login(
                                            id         in   varchar2,
                                            result_2   out  varchar2,
                                            resultbean out  PKG_LOGIN.TYPE_RECORD
                                            )  as
    
    begin
    
        result_2 := '200';
        
        open resultbean for
        select  
                SYS_ID,
                ROLE_ID,
                AUTH_ID
        from   t;        
    end  proc_login;
    
    
    CREATE OR REPLACE  PACKAGE  PKG_LOGIN
    AS
        TYPE TYPE_CURSOR  IS  REF CURSOR;
        TYPE TYPE_RECORD  IS  RECORD
        (
            SYS_ID  VARCHAR2(10),
            ROLE_ID VARCHAR2(10),
            AUTH_ID VARCHAR2(50)
        );
    END;
  • 相关阅读:
    第二周学习小结
    第一周小结(^_^)
    VS2010和搜狗快捷键冲突
    解除SQL远程编辑表
    SQLServer2005mssqlserver服务与sqlexpress服务有什么区别
    OEA界面生成学习1 总体浏览
    WPF学习:绑定
    OutLook自动存档
    文件目录学习
    AQTime
  • 原文地址:https://www.cnblogs.com/yrjns/p/10876187.html
Copyright © 2020-2023  润新知