ibatis中使用merge into

<statement id="updateCustomerRelativeWithSpouseByCustomerId4TXT" parameterClass="java.util.Map">
    merge into customer_relative a
    using (select #customerId# as customerId from dual) b
    on (a.customerid = b.customerid and a.relation = '1')
    when matched then
        update
        set updated_date = sysdate
        <dynamic>
            <isNotEmpty prepend="," property="spouse">FULLNAME=#spouse#</isNotEmpty>
            <isNotEmpty prepend="," property="spouse_mobile">MOBILE_PHONE = #spouse_mobile#</isNotEmpty>
            <isNotEmpty property="spouse_telephone_area">
                <isNotEmpty prepend="," property="spouse_telephone_code">
                    TELPHONE = #spouse_telephone_area# || '-' || #spouse_telephone_code#
                </isNotEmpty>
            </isNotEmpty>
            <isNotEmpty prepend="," property="spouse_telephone_extension">CORPEXTENSION = #spouse_telephone_extension#</isNotEmpty>
            <isNotEmpty prepend="," property="spouse_salary">MONTHLY_INCOME = to_number(#spouse_salary#)</isNotEmpty>
        </dynamic>
    when not matched then
        insert(RELATIVEID,CUSTOMERID,RELATION,FULLNAME,TELPHONE,MOBILE_PHONE,CREATED_BY,CREATED_DATE,UPDATED_BY,UPDATED_DATE,MONTHLY_INCOME,CORPEXTENSION)
        values(sys_guid(),#customerId#,'1',#spouse#,case when #spouse_telephone_area# is not null and #spouse_telephone_code# is not null then #spouse_telephone_area# || '-' || #spouse_telephone_code# end,#spouse_mobile#,'TXT',sysdate,'TXT',sysdate,to_number(#spouse_salary#),#spouse_telephone_extension#)    
</statement>

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值