1、如下所示,首先第一点,游标返回的数据不一定,想要返回map类型的,不可以直接resultType = map,只能使用resultMap来接收
2、select上要声明statementType="CALLABLE",不然奇奇怪怪的报错
Mybatis中
<resultMap type="java.util.HashMap" id="cursorMap">
</resultMap>
<select id="getMsgExtFields" statementType="CALLABLE" resultType="java.util.Map" databaseId="oracle">
{call proc_msg_ext_fields(
#{msgType, mode=IN, jdbcType=VARCHAR},
#{encId, mode=IN, jdbcType=VARCHAR},
#{primaryKey, mode=IN, jdbcType=VARCHAR},
#{bizTime, mode=IN, jdbcType=TIMESTAMP},
#{cv_1, mode=OUT, jdbcType=CURSOR,javaType=ResultSet,resultMap=cursorMap}
)}
</select>
存储过程
create or replace procedure proc_msg_ext_fields (
v_msgType in varchar2,
v_encId in varchar2,
v_primaryKey in varchar2,
v_bizTime in timestamp,
cv_1 out sys_refcursor
)
as
begin
open cv_1 for select '补充数据' as name from dual;
end;
网友评论