2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

update or insert based on data

Hi,

I have two tables  names Source,destination.

Daily some data will be inserted or updated to source.

At the end of the date i need to add this data to destination.

Daily EOD both the tables should have same data.

How can i do this.

I think daily i can drop the destination table and recreate it based on source table. But that is not a right approach with live data.

If i use trigger it will update immediately. I want this to be done at EOD only.

Please help me in this

userimage

MERGE INTO test1 a

  USING  test2 b

    ON (a.column = b.column)

  WHEN MATCHED THEN

    UPDATE SET a.status = b.status

  WHEN NOT MATCHED THEN

    INSERT (object_id, status)

    VALUES (b.object_id, b.status);


Here you just need to have primary key column in the table.

Because if you have duplicate data primary key will not accept the duplicate data.

Answer is