Having a table that is referenced in several tables, how can I execute a script that attempts to delete every record in that table without terminating on the first exception?
Posted on 2011-10-31
I have a table that is used in several other tables as a foreign key. If the table is referenced in only one specific table, I want the delete to be allowed and to cascade on delete. However, if there exists references in other tables, the delete should fail.
I want to test this with my data set by attempting to delete every record. No records should be deleted except for the last one. However, when I attempt to delete every record, it errors (as expected) and terminates the rest of the statement (doesn't proceed past the error).
How can I write a script that attempts to delete every record in a table and not terminate the statement on the first error?