Validate a field with a check contraint using regular expression does not work
So I created the following CONSTRAINT check for the field:
ALTER TABLE CERTIFICAT ADD
(
CONSTRAINT chk_cervcdmotifmodifcertf CHECK
(REGEXP_LIKE(cervcdmotifmodifcertf ,'^[0[1-9][0-9]|[1-2][0-9][0-9]|30[0-3]|400$'))
);
So, if I get a value like "000", it's not supposed to be OK. The check constraint validate it and must send an error message. But, if I try it ...
SQL> alter session set current_schema=AGRMDHD1;
Session modifiée.
SQL> update certificat
2 set cervcdmotifmodifcertf = '000'
3 where pkcer= 340893;
1 ligne mise à jour.
SQL>
The check constraint of the table validate it and it's not an error. Why ? What I do wrong ?
I also try another thing. I dropped the check constraint and tried manage the check in a trigger for the table.