postgresql如何兼容MySQL if函数(post meridiem)满满干货

随心笔谈11个月前发布 admin
93 0

<insert id=”insertBatch” parameterType=”java.util.List”>
? ? <if test=”_databaseId==’mysql’ or _databaseId==’postgresql'”>
? ? ? ? insert into table_name?
? ? ? ? (<include refid=”insertBatchColumn”></include>)
? ? ? ? values
? ? ? ? <foreach collection=”list” item=”item” index=”index” separator=”,” >
? ? ? ? ? ? (<include refid=”insertBatchValue”></include>)
? ? ? ? </foreach>
? ? </if>
? ? <if test=”_databaseId==’oracle'”>
? ? ? ? insert all
? ? ? ? <foreach collection=”list” item=”item” index=”index” separator=””>
? ? ? ? ? ? into table_name?
? ? ? ? ? ? (<include refid=”insertBatchColumn”></include>)
? ? ? ? ? ? values (<include refid=”insertBatchValue”></include>)
? ? ? ? </foreach>
? ? ? ? select * from dual
? ? </if>
</insert>
?
<sql id=”insertBatchColumn”>
? ? id,name,age,gender
</sql>
<sql id=”insertBatchValue”>
? ? #{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR},?
? ? #{item.age,jdbcType=INTEGER},#{item.gender,jdbcType=INTEGER}
</sql>

© 版权声明

相关文章