Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why can I not add a check constraint that makes the user enter an email ending in a specific address

Implementing: An employee email address should use the company domain. That is, the
email address should end with ‘abcco.com’.

alter table employee
add constraint emp_email_check check (co_email in ('%abcco.com'));

but I get this error

ORA-02293: cannot validate (ITAM.EMP_EMAIL_CHECK) - check constraint violated
02293. 00000 - "cannot validate (%s.%s) - check constraint violated"
*Cause:    an alter table operation tried to validate a check constraint to
           populated table that had nocomplying values.
*Action:   Obvious

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The IN() predicate tests for exact string matches only. It does not support wildcards.

You should use

check (co_email like '%abcco.com')

Or alternatively:

check (left(co_email, 9) = 'abcco.com')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading