Tim Bunce [EMAIL PROTECTED] wrote:
> On Mon, Sep 29, 2003 at 09:32:10AM -0400, Hardy Merrill wrote:
> > Thomas A. Lowery [EMAIL PROTECTED] wrote:
> > > # Does the error message contains the phrase: duplicate key
> > > if ($dbh->errstr =~ m/duplicate\skey/i) {
> > ^^^^^^^^^^^^^^
> > Just to clarify, as Thomas said above, each database produces
> > different error messages to indicate that you are trying
> > to insert a duplicate key - so what you search for here will
> > vary depending on which database you are using.
>
> Of course, in an ideal world, DBD's would all set $DBI::state
> ($h->state) to the appropriate value: "23000"
>
> Maybe someone could define a list of the errors that most frequently
> need to be explicitly checked for. The DBI spec could then list
> those along with the standard SQL_STATE error codes and suggest that
> drivers support at least that basic set of codes.
I think this is an excellent idea!
The only situation I can think of that I've had to code
around where different databases produce different results
is this one - this "trying to insert a duplicate record"
error. There must be others ;-)
--
Hardy Merrill
Red Hat, Inc.