<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>