MyBatis use Oracle Merge into statement to pit the record

Source: Internet
Author: User



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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.