On Mon, Sep 29, 2003 at 10:19:46PM +0100, Andy Hassall wrote:
> >
> >   23000 Integrity constraint violation  SQLBulkOperations
> >                                         SQLExecDirect
> >                                         SQLExecute
> >                                         SQLParamData
> >                                         SQLSetpos
> >
> >   40002 Integrity constraint violation  SQLEndTrans
> 
>  23000 and 40002 appear to match, but do they cover all constraints (primary
> key, unique, check, and foreign key).
> 
>  It looks like the difference between 23000 and 40002 is that 23000 is the
> result of a constraint violation, but 40002 is a constraint violation and
> the database has forced a rollback (i.e. you tried to commit violating data
> [so you must have had constraints deferred], so it rolls back instead).

Yes. (Though I can't see why they bothered to add an extra code for
it when 23000 would have been fine.)

>  Seems a bit of a mess :-(

Fun isn't it :)

I don't see a big problem with code that's trying to be very
portable having to check for a small number of specific codes
(23000, 40002, 72000 etc)

That's still a much better situation than trying to match error
strings.

Most apps don't need that level or portability and could just use
the relevant code for their database.

Tim.

Reply via email to