I want to delete rows in Oracle tables which are connected with foreign key. In order to delete row from table I have two options:
-
Two DML statements which must be run in strict order.
-
Oracle before delete Trigger on the primary key table.
Which approach is better? I’m using JDBC Oracle thin driver with Java 7.
Don’t put a trigger. You shouldn’t hide important stuff like that.
CASCADE is an option, but personnaly I would go for a stored procedure which does the delete. So the guy who wants to delete a line has to use the procedure and he (she) knows it’ll also delete lines in the daughter table.