1 rows have been created. SQL> commit; ----Without a WHERE clause sql> merge into merge1 2 using merge2 & Nbsp;3 ON (merge1.id = merge2.id) 4 When matched then 5 UPDATE&NBSP;&NBS P;6 set merge1.name = merge2.name; 3 line has been merged. SQL> rollback; fallback is complete. ---with WHERE clause sql> merge into Merge1 a 2 using merge2 b 3 on (a.id = b.id) 4 when matched then 5 update 6 set a.name = b.na Me 7 WHERE A.name <> b.name; 0 rows are merged. ------If you want to update the B table, this will make an error sql> merge into Merge1 a 2 using Merge2 b 3 on (a.id = b.id) 4 when matched then 5 UPDATE&NBSP;&NBSP;6 Set b.name = a.name; Set b.name = a.name * 6th error occurred: ORA-00904: "B". " NAME ': Invalid identifier----------------------------------------
; MERGE into loanee P
USING (SELECT * from @TApply as NC) C on P.applicationid=c.applicationid
when matched then UPD ATE set P.updatetime=getdate ()
When not matched by TARGET then INSERT
(
Loaneenumber,loaneename,loandate, Lockmatchratio,surplusmatchratio,
Matchratio,matchamount,lockamount,loaneeamount,expectedyield,
Loanperiod,creditrating,freestate,updatetime,addtime,
Deletestate,isfullstate,fulltime,loaneetype, ApplicationID,
Cashaccountno,contracttime,relaseratio,matchorder,ksshdate,
Lockstate,cashaccountno_name, Loaneesource,broker_cashaccount,broker_cashaccountname,approvaltime)
VALUES (
c.loaneenumber,c.[ loaneename],c.[loandate],0,1,
0,0,0,c.[loaneeamount],c.[expectedyield],
C.[loanperiod],c.[creditrating], 0,getdate (), GETDATE (),
0,0,null,0,c.[applicationid],
C.[cashaccountno],c.[contracttime],0,c.[matchorder] , [Ksshdate],
0,c.[cashaccountno_name],0,c.[broker_cashaccount],c.[broker_cashaccountname],c.approvaltime
);
The effect of the above example is that when inserting data into a table, it is determined whether it exists, does not exist, is inserted, and there is an update
Merge into Usage