[置顶] mybatis调用orcale存储过程-传入多个参数返回单个字符

时间:2022-07-15 08:38:50

mybatis.xml配置:

<!-- 存错过程测试 传入map(多参数) 返回单个字符 -->
<parameterMap type="java.util.Map" id="map1">
<parameter property="loginName" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" />
<parameter property="loginPassword" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" />
<parameter property="resultData" jdbcType="VARCHAR"
javaType="java.lang.String" mode="OUT" />
</parameterMap>
<select id="procedureTest1" statementType="CALLABLE" parameterMap="map1">
<![CDATA[
CALL procedureTest_01(?,?,?)
]]>
</select>

存储过程:

create or replace procedure procedureTest_01(login_user in varchar2,login_password in varchar2,resultData out varchar2)
as counts int;
s_sql varchar2(200);
begin
s_sql:='select count(user_id) from ZD_USER_MANAGE where USER_LOGIN='''||login_user||''' and USER_PASSWORD='''||login_password||''' and USER_STATUS=''1'' ';
execute immediate s_sql into counts;
resultData:=counts;
end procedureTest_01;