Is it possible to modify several tables, using the merge
function in Oracle?
In each case different operations need to be taken, like:
MERGE INTO users tab1
USING(SELECT 1 id, 10 points FROM dual) tab2
ON(tab1.id = tab2.id )
WHEN MATCHED THEN
UPDATE SET points = tab2.points
UPDATE "abc" = action.status -- another table
WHEN NOT MATCHED THEN
INSERT(id, points) VALUES(tab2.id, tab2.points)
UPDATE "def" = action.status -- another table
According the the documentation, the simple answer is no. The syntax supports one table or view. However, with an updateable view, you could accomplish a multi-table insert/update.
Your example however seems to try to do something else you cannot do. The WHEN MATCHED clause specifies what to UPDATE. You cannot INSERT from this clause. Same thing for the WHEN NOT MATCHED clause - you cannot UPDATE from this clause, only INSERT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With