The new Oracle 9i merge statement allows inserting a new row or updating an existing row in a destination table based on matching records from a source table, without using PL/SQL. The database handles matching records between tables specified in the merge statement and conditionally performs inserts or updates. An example demonstrates merging records from a cust_changes table into a customers table by customer ID, updating matching records or inserting non-matching records.
The new Oracle 9i merge statement allows inserting a new row or updating an existing row in a destination table based on matching records from a source table, without using PL/SQL. The database handles matching records between tables specified in the merge statement and conditionally performs inserts or updates. An example demonstrates merging records from a cust_changes table into a customers table by customer ID, updating matching records or inserting non-matching records.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
The new Oracle 9i merge statement allows inserting a new row or updating an existing row in a destination table based on matching records from a source table, without using PL/SQL. The database handles matching records between tables specified in the merge statement and conditionally performs inserts or updates. An example demonstrates merging records from a cust_changes table into a customers table by customer ID, updating matching records or inserting non-matching records.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
The new Oracle 9i merge statement enables you to conditionally insert a
new row or update an existing row in the destination table without having to use PL/SQL. All the hard work is done by database itself, you just have to specify the source and destination tables.
Example:
MERGE INTO customers old
USING cust_changes new ON (new.cust_id=old.cust_id) WHEN MATCHED THEN UPDATE SET old.cust_name=new.cust_name, old.cust_addr=new.cust_addr; WHEN NOT MATCHED THEN INSERT (cust_id,cust_name,cust_addr) VALUES (new.cust_id,new.cust_name,new.cust_addr);