MySQL Forums
Forum List  »  Connector/ODBC

Constraint violation
Posted by: Vincent Kirsch
Date: October 21, 2004 12:54AM

Hello all

I work on a clien/server application that uses ODBC to access a database. It is done through a "generic"-ODBC layer. We do so because it is flexible and we can face any client-specific demand regarding the DBMS they want to use. We developped that layer in C.

I currently work on a MySQL 4.1.3-beta DB on a Windows 2000 server, with th InnoDB engine.

When a foreign key constraint is violated during execution, the error message delivered by MySQL is somewhat poor in description. For instance if I try to delete a record that is still referenced in a table, the message I get is "Cannot delete or update a parent row: a foreign key or constraint fails". This causes me a problem because when the ODBC-layer is used with say DB2, the error message tells me which constraint was violated, and I can use that to send meaningful information to the client station, which can display a correct error message. Currenly I can do that with MySQL, and all the client gets is a default error message. So my question is: when a constraint violation occurs, is there any way to programatically know which one was?

During my research on that topic I came accross this link concerning Mimer:

http://developer.mimer.se/howto/howto_47.htm

Basically it explains how to get that additionnal info using stored procedures. Is there a possiblity to do that with MySQL too?

Thanks.

Options: ReplyQuote


Subject
Written By
Posted
Constraint violation
October 21, 2004 12:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.