in reply to My update on insert error solution

PeterKaagman:

It's hard to see how $sth_update wouldn't execute if you're seeing the "Doing update" message. How do you know it's not executing? Could a later update be overwriting the data from an earlier update?

I'd suggest making your traces a little more informative, so you can see what's happening:

if (! $sth_insert->execute( $$data{'id'}, $$data{'name'} ) ) { print 'Insert error: '.$sth_insert->errstr if $debug; print "Doing update (name: $$data{name}, id: $$data{id})\n"; $sth_update->execute( $$data{'name'}, $$data{'id'} ) or die("Insert and Update failed, update: +".$sth_update->errstr ); } else { print "Inserted (name: $$data{name}, id:$$data{id})\n"; }

Then you can verify that the values in the table match the last value for the ID found in your debug traces.

...roboticus

When your only tool is a hammer, all problems look like your thumb.