- 调用存储过程:
存储过程所在package为:FPMS_INTF,存储过程名为:FPMS_GETAGREEMENTAPP,参数中i开头为入参,o开头为返回参数,其中o_result,mode=OUT,jdbcType=CURSOR为返回的游标,返回类型为qryCusPurRecordBean通过resultMap=qryCusPurRecordBean进行映射。
<resultMap id="qryCusPurRecordBean"
type="com.sz.icbc.bean.fpms.FPMS_GETAGREEMENTAPPBean">
</resultMap>
<!-- 查询产品认购申请记录 -->
<select id="qryCusPurRecord" parameterType="java.util.HashMap"
statementType="CALLABLE" resultType="java.util.HashMap">
{call
FPMS_INTF.FPMS_GETAGREEMENTAPP(#{i_agreementno,mode=IN,jdbcType=VARCHAR},
#{i_productcode,mode=IN,jdbcType=VARCHAR},
#{i_begindt,mode=IN,jdbcType=VARCHAR},
#{i_enddt,mode=IN,jdbcType=VARCHAR},
#{i_productchl,mode=IN,jdbcType=VARCHAR},
#{i_payacct,mode=IN,jdbcType=VARCHAR},
#{i_status,mode=IN,jdbcType=VARCHAR},
#{o_result,mode=OUT,jdbcType=CURSOR,
resultMap=qryCusPurRecordBean},
#{o_retcode,mode=OUT,jdbcType=VARCHAR},
#{o_errmsg,mode=OUT,jdbcType=VARCHAR})}
</select>
controller中使用方式:
Map<String, Object> map = new HashMap<>();
map.put("key","value");//map对象放入入参
fpmsRecordMapperService.qryCusPurRecord(map);//调用上述存储过程对应的mapper方法
//这里注意,直接使用上边mapper方法入参map进行取值:
String retCode = map.get("o_retcode");//同样的方式取其它返回参数
ps:如果创建新的map进行接收mapper方法返回的结果,则对象为空
-
if语句
使用示例:判断入参fileType,进而确定where子句
<select id="getFTPFileInfo" resultType="java.util.HashMap">
select a.* From fpms_file_detail a, fpms_product b
where b.PRODUCTCODE=#{procode} and fileType='1'
<if test='fileType == "1" '>
and a.FILEID_FK=b.fileid1
</if>
<if test='fileType == "2" '>
and a.FILEID_FK=b.fileid2
</if>
</select>
- foreach 使用
特殊符号转译:
特殊符号 | 转译后 |
---|---|
& | & |
< | < |
> | > |
<select id="qryRoadSignRecord" resultType="com.sz.icbc.bean.fpms.RoadRecordBean">
SELECT a.*,b.productname,b.productcode
FROM fims_autored_agree a,fpms_product b
WHERE substr(a.AGREEMENTNO,9,8)=b.productcode
and a.debaccno in
<foreach collection="list" item="cardNo" index="index" open="(" close=")" separator=",">
#{cardNo}
</foreach>
<if test="begDay != null"> and a.workdate >= #{begDay} </if>
<if test="endDay != null"> and a.workdate <= #{endDay} </if>
order by a.agreestatus asc,a.workdate desc,a.worktime desc
</select>
ps:
增、改语句使用记录
- 插入
<insert id="insertFileVersionInfo" >
insert into fpms_filever_control
values(#{fileid},#{versionid},'01',#{ip})
</insert>
- 更新
<update id="updateFileVersion" parameterType="java.lang.String">
update fpms_filever_control set VERSIONID=#{versionid}
where FILEID=#{fileid} and IP=#{ip} and CHANNELID='01'
</update>
- select统计:
<select id="isExistExpose" resultType="Integer">
Select count(*) as
totalNum From Fpms_File_Detail
Where Productcode=#{Productcode} and
filetype='3'
</select>