You can create a trigger that validates a given string with a regular expression that describes the email structure
^[A-Za-z0-9] +@ [A-Za-z0-9]+.[A-Za-z0-9]+$
However, email regular expression is not easy to determine: Using regular expression to validate email addresses
DECLARE RET VARCHAR(32); SET RET = XMLCAST ( XMLQUERY ('fn:matches($TEXT,"^[A-Za-z0-9] +@ [A-Za-z0-9]+.[A-Za-z0-9]+$")' PASSING TEXT AS "TEXT" ) AS VARCHAR(32));
Once you have a RET value (true or false), you can do something in the trigger.
You can check the regex that you want to use from the command line:
db2 "xquery fn:matches(\" johndoe@mail.com \",\"^[A-Za-z0-9] +@ [A-Za-z0-9]+.[A-Za-z0-9]+$\")"
source share