Mybatis 定义 Oracle 存储过程,并获取存储输出字符串信息

存储过程

CREATE OR REPLACE procedure "m_proc"(p_message out NVARCHAR2) 

AS

...

BEGIN

...

END;

  

Mybatis

<select id="refresh" statementType="CALLABLE" parameterType="Map">
    {call m_proc(#{p_message, mode=OUT, jdbcType=VARCHAR})}
</select>


Mapper接口定义

void refresh(Map<String, Object> map);


函数调用定义

Map<String, Object> params = new HashMap<>();
PmdeCrMapper.refresh(params);

return params.get("p_message").toString();

  

注意:在获取输出信息时,map中key应和mybatis中定义占位符名相同

mybatis: {call m_proc(#{p_message, mode=OUT, jdbcType=VARCHAR})}
函数调用: return params.get("p_message").toString();

  

原文地址:https://www.cnblogs.com/m2492565210/p/15417187.html