MySQL Forums
Forum List  »  Triggers

Re: How to Raise Error ?
Posted by: Roland Bouman
Date: November 18, 2008 12:45PM

Hi!

this is currently not possible in a clean way. Proper support for raising errors is added in 6.1 (alpha - development tree)

You can work around it by causing a runtime error in some other way. If your table has some not nullable columns, the easiest way is to set those to NULL in case you detect invalid input. If you do that in the BEFORE trigger, the trigger will fail due to the NOT NULL constraint violation.

Of course, its ugly because the client cannot discern between a real NOT NULL violation and this deliberate action. You can work around that by setting a user-defined variable to indicate what really happened.

I know it is ugly but this is unfortunately the best you can do atm.

regards,

Roland.

Roland Bouman
http://rpbouman.blogspot.com/

Options: ReplyQuote


Subject
Views
Written By
Posted
25290
November 17, 2005 04:00AM
16830
November 17, 2005 06:58AM
23790
November 19, 2005 08:53AM
14601
February 23, 2006 02:28AM
10868
February 23, 2006 04:42AM
15593
February 24, 2006 08:28AM
8572
February 24, 2006 10:15AM
6351
February 24, 2006 12:42PM
7971
February 27, 2006 08:56AM
6764
February 27, 2006 11:27AM
18972
February 28, 2006 05:22AM
6623
December 20, 2006 03:34AM
4175
November 18, 2008 08:28AM
Re: How to Raise Error ?
4837
November 18, 2008 12:45PM
6257
December 19, 2006 11:00AM
5060
December 19, 2006 02:35PM
6302
December 19, 2006 07:53PM
4488
December 20, 2006 03:37AM
4700
December 19, 2006 11:01AM
5578
November 24, 2006 05:32AM
4546
November 24, 2006 07:02AM
3686
December 23, 2008 06:08AM
11338
February 25, 2006 11:48PM
5025
December 19, 2007 04:24AM
4006
December 24, 2008 01:02PM
4828
December 19, 2007 03:59AM
4709
December 19, 2007 05:09AM
3586
November 18, 2008 08:25AM
3970
November 18, 2008 12:49PM
6085
December 19, 2007 04:46AM


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.