How can I use oracle merge statement using Mybatis?
Call the merge as below:-
<update id="exceMerge" parameterType="hashmap"> MERGE INTO USERS U USING DUAL ON (U.PROPERTY_NAME=#{prop_name}) WHEN MATCHED THEN UPDATE SET U.PROPERTYVALUE=#{prop_value}, U.MESSAGE=#{message,javaType=String,jdbcType=CLOB} WHEN NOT MATCHED THEN INSERT(PROPERTY_NAME, PROPERTYVALUE, MESSAGE) VALUES (#{prop_name},#{prop_value},#{message,javaType=String,jdbcType=CLOB})</update>
I'd suggest using a stored procedure, although you may also try just pasting your code into <update>
tag.
Calling stored procedures in MyBatis is easy, after you define a procedure in your DB simply follow this example.
Note that in case where your procedure doesn't return any parameters, the procedure call should be in <update>
tag (instead of <select>
, as in example).