Oracle pl/sql: executing dynamic delete within a transaction

Clash Royale CLAN TAG#URR8PPPOracle pl/sql: executing dynamic delete within a transaction
I need to delete one or more row from list of tables stored in a table, and commit only if all deletion succeed.
So I wrote something like this (as part of a bigger procedure):
BEGIN
SAVEPOINT sp;
FOR cur_table IN (SELECT * FROM TABLE_OF_TABLES)
LOOP
EXECUTE IMMEDIATE 'DELETE FROM ' || cur_table.TABNAME || ' WHERE ID = :id_bind'
USING id;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT sp;
END;
I know this couldn't work, because of the "execute immediate".
So, what is the correct way to do that?
I haven't tried yet. I guess "execute immediate" commit itself. Is that wrong?
– MonkeyH
1 hour ago
it does not commit
– Aleksej
1 hour ago
id doesn't seem to be defined anywhere. Also, an anonymous block like this will roll back on failure anyway, so you don't need the savepoint and exception handler.– William Robertson
31 mins ago
id
Yes, my fault. It's part of a bigger procedure.
– MonkeyH
3 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
what is the issue? are you having an error, a wrong result, ... ?
– Aleksej
1 hour ago