On Tue, Sep 30, 2003 at 01:31:57PM -0400, Ronald J Kimball wrote: > On Tue, Sep 30, 2003 at 06:24:27PM +0100, Tim Bunce wrote: > > On Tue, Sep 30, 2003 at 08:57:35AM -0400, Hardy Merrill wrote: > > > > > > My thought was that we'd > > > somehow want to know specifically that the violation is caused > > > by an attempt to insert a duplicate key, but 23000 is a > > > "generic" constraint violation error. Is a generic constraint > > > violation error what we want for this? > > > > It's all the standard gives you. > > > > If you need more details there's always $h->errstr ... > > I like the idea of having standard error values to check for, but if we > have to fall back to $dbh->errstr() anyway, I'm not sure what we're gaining > from this. Personally, I've written a lot of code that checks for unique > constraint violations. Detecting a generic constraint violation, without > knowing what type of constraint was violated, just doesn't seem very > useful to me.
I think a lot of people/applications would be happy to have a standard way to check for a constraint violation; knowing that in their lives, and their databases e.g., mysql with MyISAM tables, the only constraint violation on an insert would be due to a duplicate key. Tim.
