Page 1 of 1

SQL Exception handling

Posted: 13.09.2012, 15:04
by ga_301
I am evaluating zeoslib for my project.
Is there a way to identify standard SQL errors (like for instance a Unique Key violation) by any other means than doing a string comparison with a implementation-dependent error string?
How can I retrieve either the native error code (from looking at the DBC code, this does not seem to be included in the Exception object) or (better) a database-independent error code for several kinds of SQL error.
If there would be a method on the connection to retrieve the native error code, I could probably implement the necessary mappings for the database engines in question myself.
Why not include a record in the exception object, which can hold any DB specific error information?

Why do I need this?
I have a application-defined lock table, in which the failure of inserting a record (unique key violation) means that a lock is in place. I need to be distinguish this situation from other possible SQL errors, though.

Regards,
Gunnar