oracle 在 APEX 中添加电子邮件检查约束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4389432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:08:38  来源:igfitidea点击:

Adding an email check constraint in APEX

oracleemail-validationcheck-constraintsoracle-apex

提问by Ross

I'm fairly new to Oracle and very new to APEX. I'm trying to add a constraint on a table to validate the email:

我对 Oracle 还很陌生,对 APEX 也很陌生。我正在尝试在表上添加约束以验证电子邮件:

REGEXP_LIKE(CALLER_EMAIL, '[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}')

Now if I'm right this would work fine inside a CONSTRAINT <name> CHECK(REGEXP_LIKE(...))however I get this (confusing) error when I attempt to save it:

现在,如果我是对的,这可以在 aCONSTRAINT <name> CHECK(REGEXP_LIKE(...))中正常工作,但是当我尝试保存它时会出现这个(令人困惑的)错误:

ORA-00920: invalid relational operator

ORA-00920: 无效的关系运算符

I think it is because the generated query contains "CALLER_EMAIL":

我认为这是因为生成的查询包含"CALLER_EMAIL"

alter table "CALL" add constraint
"CALL_EMAILFORMAT_CHK" check ( "CALLER_EMAIL" REGEXP_LIKE(CALLER_EMAIL, '[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}'))

Any ideas?

有任何想法吗?

采纳答案by DCookie

Try this:

尝试这个:

alter table "CALL" add constraint
"CALL_EMAILFORMAT_CHK" check 
   ( REGEXP_LIKE(CALLER_EMAIL, '[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}'));