http://www.perlmonks.org?node_id=1013931


in reply to Reaped: Re: DBI fails to return an error code
in thread DBI fails to return an error code

Don't know if its bad form to revive this post but I have found a sort of workaround. Note that this is the top link on google search, so its still relevant imho.

Having finally said goodbye to XP I have had the same problem and it's kicking my butt. Not having errors kick out is very inconvenient, not to mention possibly professionally dangerous! Also adding in die to the execute call creates a false negative!

All my research points to it being a bug with Windows 7 64 bit. Having just upgraded EVERYTHING in my cpan collection, it looks like its still live.

The (partial) workaround I found is to call $DBI::rows if $DBI::rows is <0 - specifically -1 then the sql call failed. if it is positive then the call is OK. Have it print out your SQL to the console if -1 and test it in myphpamin or whatever to get the error.

Point is, for insert/update at least its a reliable way to at least get some idea of how your statement worked!

Now I haven't tested much further than inserting. But I imagine that in other cases it should perform in a similar way.

It's not groundbreaking, I know, but I hope it helps someone else who banged their head against the wall over this!