Your approach is somewhat reasonable and I can think of a few ways to improve it but why do people say it's *bad*?
I would do the following to improve the situation:
look at $@ and make a decision based on PK error or another error.
wrap the second execute in an eval also
if the second execute fails, write that to a log
-derby
Comment on Re: Of Mysql, DBI and PK best practices