ibatis 存储过程写法
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="DepartmentInfoModel" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <alias>
<typeAlias alias="DepartmentInfoModel" type="Dscf.Global.Employee.Model.DepartmentInfoModel,Dscf.Global" />
</alias> <!--门店树 传参-->
<parameterMaps>
<parameterMap id="selectMap_Dept_DeptInfo" class="DepartmentInfoModel">
<parameter property="Idenid" column="Idenid"/>
</parameterMap>
</parameterMaps> <resultMaps>
<resultMap id="selectMap_T_DepartmentInfo" class="DepartmentInfoModel">
<result property="DepId" column="DepId"/>
<result property="DepName" column="DepName"/>
<result property="ParentDepId" column="ParentDepId"/>
<result property="DepCode" column="DepCode"/>
<result property="CustomerServicePhone" column="CustomerServicePhone"/>
<result property="RevolvingLoanPhone" column="RevolvingLoanPhone"/>
<result property="EarlyRepayPhone" column="EarlyRepayPhone"/>
<result property="Email" column="Email"/>
<result property="SignAddress" column="SignAddress"/>
<result property="SignZipCode" column="SignZipCode"/>
<result property="IsDeleted" column="IsDeleted"/>
<result property="SignCity" column="SignCity"/>
<result property="IsEnable" column="IsEnable"/>
<result property="LastOperateId" column="LastOperateId"/>
<result property="LastUpdateTime" column="LastUpdateTime"/>
<result property="CreateTime" column="CreateTime"/>
<result property="OperateId" column="OperateId"/>
<result property="IsReceiveEmail" column="IsReceiveEmail"/>
</resultMap> <!--门店树 返回值 -->
<resultMap id="selectMap_T_DepartmentInfoTree" class="DepartmentInfoModel">
<result property="DepId" column="DepId"/>
<result property="SignZipCode" column="SignZipCode"/>
<result property="IsDeleted" column="IsDeleted"/>
<result property="SignCity" column="SignCity"/>
<result property="IsEnable" column="IsEnable"/>
<result property="LastOperateId" column="LastOperateId"/>
<result property="LastUpdateTime" column="LastUpdateTime"/>
<result property="CreateTime" column="CreateTime"/>
<result property="OperateId" column="OperateId"/>
<result property="DepName" column="DepName"/>
<result property="ParentDepId" column="ParentDepId"/>
<result property="DepCode" column="DepCode"/>
<result property="CustomerServicePhone" column="CustomerServicePhone"/>
<result property="RevolvingLoanPhone" column="RevolvingLoanPhone"/>
<result property="EarlyRepayPhone" column="EarlyRepayPhone"/>
<result property="Email" column="Email"/>
<result property="SignAddress" column="SignAddress"/> <result property="ParentName" column="ParentName"/>
<result property="sort" column="sort"/>
<result property="level" column="level"/>
<result property="IsReceiveEmail" column="IsReceiveEmail"/>
</resultMap>
</resultMaps> <statements>
<!-- 查询 需要后动修改分页时的排序字段 -->
<select id="select_T_DepartmentInfo" resultMap="selectMap_T_DepartmentInfo" resultClass="DepartmentInfoModel" parameterClass="DepartmentInfoModel">
SELECT
<isNotNull property="TopNums">
<![CDATA[ top $TopNums$]]>
</isNotNull>
MAX(row_n) over(partition by ) as TotalItems, *
FROM
(
<!-- ********* 必须要修改 order by a.Id ********* -->
SELECT ROW_NUMBER() OVER ( PARTITION BY ORDER BY a.DepId) AS row_n,a.DepId,a.DepName,a.ParentDepId,a.DepCode,a.CustomerServicePhone,a.RevolvingLoanPhone,a.EarlyRepayPhone,a.Email,a.SignAddress,a.SignZipCode,a.IsDeleted,a.SignCity,a.IsEnable,a.LastOperateId,a.LastUpdateTime,a.CreateTime,a.OperateId,a.IsReceiveEmail
FROM T_DepartmentInfo as a
<dynamic prepend="where"> <isNotNull prepend="and" property="DepId">
<![CDATA[ a.DepId=#DepId# ]]>
</isNotNull> <isNotNull prepend="and" property="IsReceiveEmail">
<![CDATA[ a.IsReceiveEmail=#IsReceiveEmail# ]]>
</isNotNull> <isNotNull prepend="and" property="DepName">
<![CDATA[ a.DepName=#DepName# ]]>
</isNotNull> <isNotNull prepend="and" property="ParentDepId">
<![CDATA[ a.ParentDepId=#ParentDepId# ]]>
</isNotNull> <isNotNull prepend="and" property="DepCode">
<![CDATA[ a.DepCode=#DepCode# ]]>
</isNotNull> <isNotNull prepend="and" property="CustomerServicePhone">
<![CDATA[ a.CustomerServicePhone=#CustomerServicePhone# ]]>
</isNotNull> <isNotNull prepend="and" property="RevolvingLoanPhone">
<![CDATA[ a.RevolvingLoanPhone=#RevolvingLoanPhone# ]]>
</isNotNull> <isNotNull prepend="and" property="EarlyRepayPhone">
<![CDATA[ a.EarlyRepayPhone=#EarlyRepayPhone# ]]>
</isNotNull> <isNotNull prepend="and" property="Email">
<![CDATA[ a.Email=#Email# ]]>
</isNotNull> <isNotNull prepend="and" property="SignAddress">
<![CDATA[ a.SignAddress=#SignAddress# ]]>
</isNotNull> <isNotNull prepend="and" property="SignZipCode">
<![CDATA[ a.SignZipCode=#SignZipCode# ]]>
</isNotNull> <isNotNull prepend="and" property="IsDeleted">
<![CDATA[ a.IsDeleted=#IsDeleted# ]]>
</isNotNull> <isNotNull prepend="and" property="SignCity">
<![CDATA[ a.SignCity=#SignCity# ]]>
</isNotNull> <isNotNull prepend="and" property="IsEnable">
<![CDATA[ a.IsEnable=#IsEnable# ]]>
</isNotNull> <isNotNull prepend="and" property="LastOperateId">
<![CDATA[ a.LastOperateId=#LastOperateId# ]]>
</isNotNull> <isNotNull prepend="and" property="LastUpdateTime_B">
<![CDATA[ a.LastUpdateTime>=#LastUpdateTime_B# ]]>
</isNotNull>
<isNotNull prepend="and" property="LastUpdateTime_E">
<![CDATA[ a.LastUpdateTime<=#LastUpdateTime_E# ]]>
</isNotNull> <isNotNull prepend="and" property="CreateTime_B">
<![CDATA[ a.CreateTime>=#CreateTime_B# ]]>
</isNotNull>
<isNotNull prepend="and" property="CreateTime_E">
<![CDATA[ a.CreateTime<=#CreateTime_E# ]]>
</isNotNull> <isNotNull prepend="and" property="OperateId">
<![CDATA[ a.OperateId=#OperateId# ]]>
</isNotNull> <!-- 一个例子 -->
<!--<isNotEmpty prepend="and" property="属性名">
字段名 like #属性名#
</isNotEmpty>-->
</dynamic>
) as a
<dynamic prepend="where">
<isNotNull property="PrevPageNums">
<![CDATA[ a.row_n>$PrevPageNums$]]>
</isNotNull>
</dynamic> </select> <!-- 数据分析 树-->
<procedure id="select_T_DepartmentInfoTree" parameterMap="selectMap_Dept_DeptInfo" resultMap="selectMap_T_DepartmentInfoTree" >
Proc_LoanStorDept
</procedure> <!-- 添加 -->
<insert id="insert_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
<selectKey property="DepId" type="post" resultClass="int">
${selectKey}
</selectKey>
INSERT INTO T_DepartmentInfo
(
DepName,ParentDepId,DepCode,CustomerServicePhone,RevolvingLoanPhone,EarlyRepayPhone,Email,SignAddress,SignZipCode,IsDeleted,SignCity,IsEnable,LastOperateId,LastUpdateTime,CreateTime,OperateId,IsReceiveEmail
) VALUES
(
#DepName#,#ParentDepId#,#DepCode#,#CustomerServicePhone#,#RevolvingLoanPhone#,#EarlyRepayPhone#,#Email#,#SignAddress#,#SignZipCode#,#IsDeleted#,#SignCity#,#IsEnable#,#LastOperateId#,#LastUpdateTime#,#CreateTime#,#OperateId#,#IsReceiveEmail#
) </insert> <!-- 更新 -->
<update id="update_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
UPDATE T_DepartmentInfo SET DepName=#DepName#,
ParentDepId=#ParentDepId#,
DepCode=#DepCode#,
CustomerServicePhone=#CustomerServicePhone#,
RevolvingLoanPhone=#RevolvingLoanPhone#,
EarlyRepayPhone=#EarlyRepayPhone#,
Email=#Email#,
SignAddress=#SignAddress#,
SignZipCode=#SignZipCode#,
IsDeleted=#IsDeleted#,
SignCity=#SignCity#,
IsEnable=#IsEnable#,
LastOperateId=#LastOperateId#,
LastUpdateTime=#LastUpdateTime#,
CreateTime=#CreateTime#,
OperateId=#OperateId#,
IsReceiveEmail=#IsReceiveEmail#
<!-- -->
WHERE T_DepartmentInfo.DepId=#DepId#
</update> <!--删除-->
<delete id="delete_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
DELETE FROM T_DepartmentInfo where DepId=#DepId#
</delete> <!-- 删除-->
<delete id="delete_flag_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
UPDATE T_DepartmentInfo set IsDeleted = where DepId=#DepId#
</delete>
</statements>
</sqlMap>
ibatis 存储过程写法的更多相关文章
- SQL组合查询的存储过程写法
最进一个项目 里面有个查询的功能,它是进行组合查询的, 而且用的是存储过程写.写这样的存储过程,需要注意单引号的使用,请看本人下面的例子,假如你以后写的话 记得注意写就行: create proc s ...
- mysql数据库-定义函数-存储过程写法
------------- mysql 定义自定义函数写法 DELIMITER $$ USE `iwmsdb`$$ DROP FUNCTION IF EXISTS `F_WM_DBNAME`$$ C ...
- oracle ibatis 存储过程 返回游标 嵌套表
自己解决问题了 问题总结: 1.index by表不能存储在数据库中的type中,故选择嵌套表. 2.ibatis不支持oracle的复合数据类型的返回.(个人理解) 3.替代方案:用返回oracle ...
- SQL Server分页的存储过程写法以及性能比较
------创建数据库data_Test ----- create database data_Test GO use data_Test GO create table tb_TestTable - ...
- iBATIS存储过程
使用iBATIS配置来调用存储过程.为了理解这一章,首先需要了解我们是如何在MySQL中创建一个存储过程. 在继续对本章学习之前,可以通过MySQL存储过程. 我们已经在MySQL下有EMPLOYEE ...
- Oracle存储过程写法
create or replace procedure QIANFEIGL_JIAOKUANDY( cebenh varchar2, kehuh varchar2, hetongh varchar2, ...
- mysql存储过程写法—动态参数运用
--删除 双击代码全选 1 drop procedure if exists up_common_select --创建 双击代码全选 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
- Oracle常用存储过程写法
写在前面 这段时间工作最长接触到的就是Oracle数据库,不论查数据,还是统计.运行job,都离不开PL/SQL 存储过程,下面就整理下经常用到的知识. 一.Function函数 函数是执行非查询语句 ...
- 【Oracle】存储过程写法小例子
1.存储过程的基本语法: CREATE OR REPLACE PROCEDURE 存储过程名(param1 in type,param2 out type) IS 变量1 类型(值范围); 变量2 类 ...
随机推荐
- Filter实现全站违法关键词屏蔽
思路:客户端请求服务器数据,经过Filter过滤(请求放行,响应拦截),服务器向客户端返回数据时,在Filter中修改掉返回数据中违法的部分. 修改服务器的响应需要自定义一个HttpServletRe ...
- Redis常用方法
首先构建非切片连接池jedisPool对象,写好配置redis连接的方法. /** * 构建redis切片连接池 * * @param ip * @param port * @return Jedis ...
- C#使用原生的Directx和OpenGL绘图
原文 混合语言编程-C#使用原生的Directx和OpenGL绘图的方法 由于项目需要做一些图形展示,所以就想到了使用Directx和OpenGL来绘图,但项目准备使用C#来开发(大家比较熟悉C#), ...
- Redis优化经验
内存管理优化 Redis Hash是value内部为一个HashMap,如果该Map的成员数比较少,则会采用类似一维线性的紧凑格式来存储该Map, 即省去了大量指针的内存开销,这个参数控制对应在red ...
- RPM软件包制作
参考网站:How to create an RPM package/zh-cn[教程]https://fedoraproject.org/wiki/How_to_create_an_RPM_packa ...
- codeblocks调试快捷键说明
使用codeblocks避免不了快捷键: 在调试程序的时候: 首先在view->toolbar->debugger调出来:快捷方式可以自己看 RUN to Cursor :F4 单步调试 ...
- C++学习14 继承的概念及语法
继承是类与类之间的关系,是一个很简单很直观的概念,与现实世界中的继承(例如儿子继承父亲财产)类似. 继承(Inheritance)可以理解为一个类从另一个类获取成员变量和成员函数的过程.例如类B继承于 ...
- java异常处理机制throw
- IGeoDatabaseBridge2.GetLineOfSight
IGeoDatabaseBridge2.GetLineOfSight Method Returns a line-of-site indicator interpolated from the TIN ...
- Js获取当前日期时间及时间相关操作
Js获取当前日期时间及时间格式 var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); ...