MySQL Forums
Forum List  »  Triggers

Regex in trigger not working as expected
Posted by: Jette Nielsen
Date: July 11, 2013 03:32AM

I have this piece of code inside a BEFORE UPDATE trigger:

------------------------------------------------
IF (NEW.col1 REGEXP '^[[:digit:]]{5}$') = 0 THEN
SET history = CONCAT(history,'\nCol1 value = (',NEW.col1,')');
END IF;
------------------------------------------------

Example value of "history":

Col1 value = (51011)

The strange thing is, that the regex is testing for a 5 digit value, and history should be set only if the value does NOT match, since I am testing if REGEXP returns 0.

col1 is a varchar(32).

I've spent a lot of time trying to figure this out. Gratefull for any suggestions.

Thanks :-)

Options: ReplyQuote


Subject
Views
Written By
Posted
Regex in trigger not working as expected
2763
July 11, 2013 03:32AM


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.