I could not get it, you are finding a match on tr.col1 = sr.col1, if it matches you are updating, if it does not match you will insert.
Now you want to delete before insert and criteria is again delete where tr.col1 = sr.col1, when there are no records matching this criteria , what will it delete? On Wed, Sep 15, 2010 at 8:50 AM, swaroop gowda <swaroop.t...@gmail.com>wrote: > Hi, > > I would like to know is it possible to DELETE rows from target table before > INSERT statement in MERGE statement? > > Eg: > MERGE INTO TR tr USING SR sr ON (tr.col1 = sr.col1) > WHEN MATCHED THEN > UPDATE SET tr.col2 = sr.col2 etc.... > > WHEN NOT MATCHED THEN > > DELETE WHERE tr.col1 = sr.col1; > > INSERT (tr.col1,trcol2,tr.col3) VALUES > (sr.col1, sr.col2, sr.col3); > > > -- > Thanks & Regards > Swaroop Thailuru Swamy > > -- > You received this message because you are subscribed to the Google > Groups "Oracle PL/SQL" group. > To post to this group, send email to Oracle-PLSQL@googlegroups.com > To unsubscribe from this group, send email to > oracle-plsql-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/Oracle-PLSQL?hl=en -- You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group. To post to this group, send email to Oracle-PLSQL@googlegroups.com To unsubscribe from this group, send email to oracle-plsql-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Oracle-PLSQL?hl=en