Search code examples
sqloraclemerge

pl sql. 0 rows merged


I am new to merge so this question may appear too dumb.

I'm running

MERGE INTO regions r
   USING regions_temp t
   ON (r.id_region = t.id_region)
    WHEN NOT MATCHED THEN INSERT (r.id_region, r.region_name)
     VALUES (t.id_region, t.region_name);

Before I run the command the tables have following records (id_region, region_name):

Regions:

1   1   Kiev
2   2   Asia
3   3   Australia
4   4   South America
5   5   Africa

Regions_temp:

1   1   
2   2   Asia
3   3   Australia
4   4   South America

The command runs successfully but on the bottom of the window it says 0 rows merged and no records are merged.

Little help?


Solution

  • MERGE INTO regions r
       USING regions_temp t
       ON (r.id_region = t.id_region)
        WHEN MATCHED THEN update  set r.region_name =  t.region_name
    

    is what i actually needed