//定義存儲過程
create or replace procedure pag_add(p1 varchar2,p2 varchar2,p3 out varchar2)
as
begin
p3:=p1+p2;
end;java
//定義函數
create or replace function fun_add(p1 number ,p2 number)
return number
as
begin
return p1+p2;
end;sql
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 此文件主要用於編寫sql語句
namespace是爲了解決相同名字的sql操做問題
-->
<mapper namespace="cn.et.mybatis.lesson02.func.CallMapper">
<!-- statementType 聲明指向的是什麼類型,其中CALLABLE是執行存儲過程和函數的-->
<select id="queryEmp" parameterType="map" statementType="CALLABLE">
{
call pag_add(
#{p1,mode=IN,jdbcType=NUMERIC},
#{p2,mode=IN,jdbcType=NUMERIC},
#{p3,mode=OUT,jdbcType=NUMERIC}
)
}
</select>
<!-- 定義存儲過程 -->
<select id="callProcedure" parameterType="map" statementType="CALLABLE" >
{
call prg_add(
#{p1,mode=IN,jdbcType=NUMERIC},
#{p2,mode=IN,jdbcType=NUMERIC},
#{p3,mode=OUT,jdbcType=NUMERIC}
)
}
</select>
<!-- 定義函數 -->
<select id="callFunction" parameterType="map" statementType="CALLABLE">
{
#{p3,mode=OUT,jdbcType=NUMERIC}=call fun_add(
#{p1,mode=IN,jdbcType=NUMERIC},
#{p2,mode=IN,jdbcType=NUMERIC}
)
}
</select>mybatis
<parameterMap type="com.zlkj.frm.bean.LoginBean" id="jhStart">
<parameter property="jhid" jdbcType="VARCHAR" javaType="string" mode="IN" />
<parameter property="xcmj" jdbcType="VARCHAR" javaType="string" mode="IN" />
<parameter property="sfzmhm" jdbcType="VARCHAR" javaType="string" mode="IN" />
<parameter property="code" jdbcType="VARCHAR" javaType="string" mode="OUT" />
<parameter property="message" jdbcType="VARCHAR" javaType="string" mode="OUT" />
</parameterMap>
<!-- 教育計劃開始 -->
<select id="jyjhStart" parameterMap="jhStart" statementType="CALLABLE" >
{call wlmx_business_pkg.begin_jyjh(?,?,?,?,?)}
</select>app
</mapper>less