时间:2021-07-01 10:21:17 帮助过:27人阅读
对应的Mybatis:
1 <update id="mergeIntoLianeroadmapping" parameterType="java.lang.String"> 2 MERGE INTO table B 3 USING (SELECT COUNT(C.CROSSID) AS QUNATUM FROM table C WHERE C.CROSSID = #{crossId} 4 AND C.LANEID = #{laneId} AND C.NEXTCROSSID = #{nextCrossId}) T 5 ON (T.QUNATUM > 0) 6 WHEN MATCHED THEN 7 UPDATE SET B.SBBH = ‘‘,B.LANEID = ‘6‘,B.NEXTCROSSID = #{nextCrossId} 8 WHEN NOT MATCHED THEN 9 INSERT (B.SBBH, B.LANEID, B.NEXTCROSSID,B.CROSSID) VALUES (‘‘,#{laneId},#{nextCrossId},#{crossId}) 10 </update>
1 merge语法是根据源表对目标表进行匹配查询,匹配成功时更新,不成功时插入。 2 3 其基本语法规则是 4 5 merge into 目标表 a 6 7 using 源表 b 8 9 on(a.条件字段1=b.条件字段1 and a.条件字段2=b.条件字段2 ……) 10 11 when matched then update set a.更新字段=b.字段 12 13 when not macthed then insert into a(字段1,字段2……)values(值1,值2……)
Oracle之mergeInto
标签:mybatis date oracl ppi The ane bat oracle update