> 
> 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.

I'm probably oversimplifying, but if the first execute fails, you can
rollback and run the second one, since the first one fails anyway, there's
nothing really outstanding to do.  Unless, you want to do this in a larger
loop and the larger loop needs to be in a single transaction.

Jeff



Reply via email to