This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm using Oracle and SQL Server and I have an multi-field (two-table) index set up to guarantee uniqueness for that pair of columns. When I attempt to insert a new entity via Lightspeed, I get an Oracle exception when running against Oracle. A post in a previous thread suggested catching DbException since both Oracle and SQL Server's exception in this case extends the DbException class. However, it looks like I still have to interrogate the exception in a database-type manner since Oracle and SQL Server's base exception gives different internal results (i.e., different error message, error code, etc). Is there a way to get a generic "constraint violation" exception instead of having to have specific code for both Oracle and SQL Server to determine the exact reason for the exception? Like the specific Oracle and SQL Server exceptions, catching a DbException doesn't necessarily tell me whether there's a database problem (i.e., disk error, network error) or a problem with the data being submitted on the insert (i.e., input error). After all, Lightspeed should be abstracting that for me, correct? Maybe not in the real world, but that sure would be nice. Thanks. |
|
|
Unfortunately that isn't possible at the moment. It would indeed be nice but it's not a trivial enhancement -- we'd need to analyse error codes from across all our databases, not just SQL Server and Oracle -- and it has forbidding compatibility implications -- e.g. code that currently relies on catching SqlException or OracleException would break if we started translating certain exceptions to ConstraintExceptions. A better bet in practice would be to implement an exception classifier. This could be done externally to LightSpeed and could make a handy open source project as the community could build up the classification list over time. It doesn't make for such a nice abstraction but it avoids the compatibility issue. |
|