Google News
logo
PL/SQL - Interview Questions
Explain the uses of Merge with Syntax in PL-SQL.
Merge reduces the number of table scans and performs parallel operations if required. MERGE inserts or updates data conditionally from one table to another.

For example :
MERGE INTO orders o
USING customer c
ON (o.cust_id = c.cust_id)
WHEN MATCHED THEN
UPDATE SET o.del_address = c.address
WHEN NOT MATCHED THEN
INSERT (cust_id, address)
VALUES (c.emp_id, c.address);
In this example, if a record with the matching condition is found, then the address of the same record is updated, else a new row is inserted.
Advertisement