Because the requirements involve Oracle's CLOB type field, the merge into statement is always unsuccessful in MyBatis's mapper XML file.
Attach Error code
<insert id="mergeInto">
<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id"> SELECT to_char(sysdate,‘yyyymmdd‘)||seq_dr_bcxx.nextval
AS ID FROM dual </selectKey> MERGE INTO dr_doc_info doc
USING (SELECT #{cankwxzwtm} cankwxzwtm,
#{zz} zz FROM dual) d
ON (doc.cankwxzwtm = d.cankwxzwtm and doc.zz = d.zz)
WHEN matched THEN
UPDATE SET doc.MOD_TIME = #{modTime},doc.UPD_USER = #{updUser}
WHEN not matched THEN
INSERT (
ID,
CKWXLX,
CANKWXBH,
CANKWXZWTM,
CANKWXYWTM,
ZZ,
DYZZXM,
DIYZZDW,
DYZZDZ,
TXZZDZ,
TXZZXM,
TXZZDW,
KANM,
YEAR,
JUAN,
QI,
YEMA,
ZWGJC,
YWGJC, <!-- zhongwzy, YINGWZY, --> FUND_TYPE,
FLH,
IS_OPEN, <!-- CKWXLY, --> REG_TIME,
MOD_TIME,
MEMO,
CRT_USER,
UPD_USER
)VALUES(
#{id,jdbcType=VARCHAR},
#{ckwxlx,jdbcType=VARCHAR},
#{cankwxbh,jdbcType=VARCHAR},
#{cankwxzwtm,jdbcType=VARCHAR},
#{cankwxywtm,jdbcType=VARCHAR},
#{zz,jdbcType=VARCHAR},
#{dyzzxm,jdbcType=VARCHAR},
#{diyzzdw,jdbcType=VARCHAR},
#{dyzzdz,jdbcType=VARCHAR},
#{txzzdz,jdbcType=VARCHAR},
#{txzzxm,jdbcType=VARCHAR},
#{txzzdw,jdbcType=VARCHAR},
#{kanm,jdbcType=VARCHAR},
#{year,jdbcType=VARCHAR},
#{juan,jdbcType=VARCHAR},
#{qi,jdbcType=VARCHAR},
#{yema,jdbcType=VARCHAR},
#{zwgjc,jdbcType=VARCHAR},
#{ywgjc,jdbcType=VARCHAR}, <!-- #{zhongwzy,jdbcType=CLOB,typeHandler=org.apache.ibatis.type.ClobTypeHandler},
#{yingwzy,jdbcType=CLOB,typeHandler=org.apache.ibatis.type.ClobTypeHandler}, --> #{fundType,jdbcType=VARCHAR},
#{flh,jdbcType=VARCHAR},
#{isOpen,jdbcType=VARCHAR}, <!-- #{ckwxly,jdbcType=VARCHAR}, --> #{regTime,jdbcType=TIMESTAMP},
#{modTime,jdbcType=TIMESTAMP},
#{memo,jdbcType=VARCHAR},
#{crtUser,jdbcType=VARCHAR},
#{updUser,jdbcType=VARCHAR}
) </insert>
There are three main points of concern,
Field comparisons for 1,clob types are based on function dbms_lob.compare ().
2,clob field Handwriting Insert inbound failed (not resolved).
3, the use of stored procedures is successful (do not want to use stored procedures).
MyBatis use Oracle Merge into statement to pit the record