MySQL Forums
Forum List  »  Triggers

Re: Enforce business rule with before insert trigger?
Posted by: Andrew Gilfrin
Date: April 27, 2005 04:13AM

Yes this does work, but....

Firstly it works on the premis that the table your using has a primary key constraint, also when the trigger fails it will return back to the calling program and use the primary key error message. This may be fine when your developing but it's really not a solution I would want to implement in a 'real' application.

The reason I'm against doing this is because it gives you no feedback on why the trigger failed, fine in a small trigger but not for a more complex one.

Lets say your trigger failed, which one of the 4 possible scenarios did it fail on? I can imagine the amount of time wasted by a support team looking for why the users inserts are failing a primary key check when it looks fine.

Andrew Gilfrin
My MySQL related Blog
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Edited 1 time(s). Last edit at 04/27/2005 04:16AM by Andrew Gilfrin.

Options: ReplyQuote

Written By
Re: Enforce business rule with before insert trigger?
April 27, 2005 04:13AM

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.