MySQL Forums
Forum List  »  Triggers

Re: Enforce business rule with before insert trigger?
Posted by: riccardo bongiovanni
Date: April 27, 2005 04:30AM

Andrew,

if u use this solution :

if(condition_1) then
set @insert_failed := concat(@insert_failed, "error message xxx");
elseif(condition_2) then
set @insert_failed := concat(@insert_failed, "error message xxx");
......
elseif(condition_n) then
set @insert_failed := concat(@insert_failed, "error message xxx");


in your trigger, every time the validation fails u can ADD the REAL error message to environment variable.
at the end of the trigger execution your environment variable contains ALL the real error messages.

This solution I think u can apply to every simple or complex trigger.

In this way in your 'real' application scenario users after their sql fails have to read the environment variable where there will be the real error message (not the primary constraints reason).

I hope I was clear. :-)
Riccardo Bongiovanni.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Enforce business rule with before insert trigger?
3409
April 27, 2005 04:30AM


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.