MySQL Forums
Forum List  »  Triggers

NOT NULL checked before BEFORE TRIGGER
Posted by: Ondra Zizka
Date: December 29, 2008 08:30PM

Hi,

I have a DATE NOT NULL column. I also have a BEFORE INSERT TRIGGER, that should convert the value to NOW():

CREATE TABLE tab ( col DATE NOT NULL, col2 INT );

CREATE TRIGGER tab_bi
BEFORE INSERT ON tab
FOR EACH ROW SET NEW.col = NOW();

When I do

INSERT INTO tab SET col2 = 1;

MySQL 5.0 complains about NOT NULL constraint violation.

Logically, when it's _before_ insert, I would expect it to be done _before_, and the check should happen when the trigger has set the value to NOW().

Is this a bug, or is it SQL-standard conformal? Or what is the reason for this.

Thanks, Ondra Zizka

Options: ReplyQuote


Subject
Views
Written By
Posted
NOT NULL checked before BEFORE TRIGGER
4063
December 29, 2008 08:30PM


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.