Is there any way to have a MERGE INTO statement insert rows into 2 separate tables? In the example below, t3 is a work table that will hold the value of :a when the WHEN MATCHED condition is not met. I somehow need to keep track of which values of :a are not matched and result in an inserted row rather than just an update.
(I understand that you cannot use AND in this context here, i'm using it to illustrate what I need to do)
MERGE INTO t1 USING t2 ON t1.a = t2.a AND t1.b = t2.b WHEN MATCHED THEN UPDATE SET t1.c = current_timestamp(0) WHEN NOT MATCHED THEN INSERT VALUES (:a, :b, :c) AND INSERT INTO t3 (:a)
Tags:
Forums: