I am using DBD::Pg, and I noticed that after a statement causes an
error, subsequent statements (until rollback) fail with "current
transaction is aborted, queries ignored until end of transaction".  I
found some postgres documentation[1] suggesting that it is impossible to
continue after an error.  Is this true for other drivers, and is there
an official DBI position on this?  (I couldn't find any mention in the
DBI documentation.)

It seems somewhat unfortunate that I can't (within a transaction) do
something like

    $sth = sth("delete from users where user_id = ?");
    eval { $sth->execute($id) };
    return unless $@;

    # must have been a referential integrity violation
    $sth = sth("update users set disabled = true where user_id = ?");
    $sth->execute($id);

Does anyone have suggestions for accomplishing something similar, all
within one transaction?  I don't know of any way to check for
referential integrity violations without actually trying to delete the
thing.  If I can't come up with a better solution, I guess I'll just
set disabled and forget about trying to delete.

Andrew

[1] http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

Reply via email to