mybatis oracle 语句

<sql id="Base_Column_List">
to_char(REPLAYTIME,'yyyy-MM-dd HH24:mi:ss'),  ......

</sql>

<!-- 添加  -->

<insert id="insert" parameterType="com.baidu.model.Demo">
insert into HB_ADVICE
<trim prefix="(" suffix=")" suffixOverrides=","> 
<if test="type != null">TYPE,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> 
<if test="type != null">
#{type,jdbcType=DECIMAL},
</if>
</trim>
</insert>

<!-- 更新 -->
<update id="update" parameterType="com.baidu.model.Demo">
update Table
<set>
<if test="type != null"> 
TYPE = #{type,jdbcType=DECIMAL}, 
</if> 

 ....


</set>
where ID = #{id,jdbcType=DECIMAL}
</update>

<!-- 批量刪除 -->
<delete id="delete" parameterType="java.util.Map">
DELETE FROM Table WHERE ID IN
<foreach collection="ids" item="item" index="index" open="("
separator="," close=")">#{item,jdbcType=DECIMAL}</foreach>
</delete>

<!-- 单一刪除 -->
<delete id="deleteById" parameterType="java.lang.Long">
DELETE from Table
where ID = #{id,jdbcType=DECIMAL}
</delete>


<!-- 查询数据数 -->
<select id="queryByCount" resultType="java.lang.Integer"
parameterType="java.util.Map">
SELECT COUNT(1) FROM HB_ADVICE
<include refid="Page_Where_Clause" />
</select>
<!-- 单个查询 -->
<select id="queryById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List" />
from HB_ADVICE
where ID = #{id,jdbcType=DECIMAL}
</select>

<!-- 分页查询 -->
<select id="queryByPage" resultMap="BaseResultMap"
parameterType="java.util.Map">
SELECT
<include refid="page_list_Column" />
FROM table
WHERE ROWID IN (
SELECT rid FROM (
SELECT rid,
ROWNUM
AS rn
FROM (
SELECT ROWID
rid FROM HB_ADVICE
<include refid="Page_Where_Clause" />
<![CDATA[ 
ORDER BY ${orderby}
) t1 WHERE
ROWNUM<=#{endIndex,jdbcType=DECIMAL}
) t2 WHERE
rn>#{startIndex,jdbcType=DECIMAL}
)
]]>
ORDER BY ${orderby}
</select>

<!-- 分页查询条件 -->
<sql id="Page_Where_Clause">
<where>
<trim suffixOverrides="AND | OR" prefix="1=1">
<if test="title != null and title !='' ">
AND TITLE LIKE '%' || #{title,jdbcType=VARCHAR} || '%'
</if>
<if test="name != null and ename !='' ">
AND NAME = #{name,jdbcType=VARCHAR}  
</if>
<if test="type != null and type > 0 ">
AND TYPE = #{ype,jdbcType=DECIMAL}
</if>
<if test="flag != null and flag > 0 ">
AND FLAG = #{flag,jdbcType=DECIMAL}
</if>
<if test="deal != null and deal > 0 ">
AND DEAL = #{deal,jdbcType=DECIMAL}
</if>
<if test="begintime != null and begintime !='' ">
<![CDATA[
AND CREATETIME >= to_date(#{begintime,jdbcType=VARCHAR},'YYYY-MM-DD HH24:MI:SS')
]]>
</if>
<if test="endtime != null and endtime !='' ">
<![CDATA[
AND CREATETIME <= to_date(#{endtime,jdbcType=VARCHAR} || ' 23:59:59','YYYY-MM-DD HH24:MI:SS') 
]]>
</if>
</trim>
</where>
</sql>




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

houzhanwublog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值