Merge statement in oracle

This is an example of the MERGE statement. In the following request, we will merge the source table into the target table.

 MERGE
      INTO  target_table tgt
       USING source_table src
       ON  ( src.object_id = tgt.object_id )
    WHEN MATCHED
    THEN
       UPDATE
       SET   tgt.object_name = src.object_name
       ,     tgt.object_type = src.object_type
   WHEN NOT MATCHED
   THEN
      INSERT ( tgt.object_id
             , tgt.object_name
             , tgt.object_type )
      VALUES ( src.object_id
             , src.object_name
             , src.object_type ) ;

More info : http://www.oracle-developer.net/display.php?id=203

Leave a Reply