With Oracle DB, is it possible to update one table and delete (match rows) in others?
I tried various forms of MERGE
, but I get either:
ORA-01446: cannot select ROWID from or pattern, view with DISTINCT, GROUP BY etc.
(probably caused by UNION ALL
in the view)
or
ORA-38106: MERGE is not supported in the view or view of a connection to an INSTEAD OF trigger.
This ("view join") assumes that specifying two tables in any form is no-go for MERGE
. It is right?
(reasons for using one operator: performance, consistency and clarity)
My Oracle DB has version 11.2.
The real problem is this:
We (the library) have a (parent) table of books and a (child) table of contents (one or zero per book, it has an FK in the table of books). Every year we start a work that for each book older than 10 years (let it simplify the condition, since it is not related to the problem here), we set a column with the name RETIRED for the value "YES" in the table of books and delete the line (if present) in the table content.
PS: PL / SQL solutions are welcome. (my code in PL / SQL anyway)
source share