Oracle APEX现场验证

网管系统

我有一个关于在Oracle Apex上进行字段验证的简单问题。我试图将验证放在'Work Package Name'文本字段中,'WP'然后是两位数还是'AM'两位数e.g WP00 & AM01将被接受,WP000 & AN01也将不被接受。

我不确定要选择哪个验证选项,因此我决定使用PL / SQL返回布尔值。我的代码似乎不正确(请参见下文)。

如果我是在TOAD中创建的,那么我会声明该字段名称,但是我想通过使用:P7_WP_NAMEthis可以完成相同的工作。

IF :P7_WP_NAME = WP(2,0) 
ELSE IF :P7_WP_NAME = AM(2,0)
THEN RETURN TRUE;
ELSE 
  RETURN FALSE;
END IF;

我目前收到的错误如下。我尝试重新编写代码,但不断收到不同的错误:

ORA-06550: line 2, column 1: PLS-00103: Encountered the symbol "ELSE" when expecting one of the following: . ( * % & - + / at mod remainder rem then <an exponent (**)> and or || multiset 
ORA-06550: line 7, column 18: PLS-00103: Encountered the symbol ";" when expecting one of the following: if The symbol "if" was substituted for ";" to continue.
ORA-06550: line 7, column 54: PLS-00103: Encountered the symbol    "end-of-file" when expecting one of the following: begin case declare
end exception

如果您能告诉我这是否是使用的最佳验证选项以及我出了什么问题,我将不胜感激。

雷内

我对正则表达式不太满意,但可以尝试一下:

begin
   if regexp_like(:P7_WP_NAME,'^WP\d{2}$')
   or regexp_like(:P7_WP_NAME,'^AM\d{2}$')
   then
      return true;
   else
     return false;
   end if;
end;

regexp可能简化为:

regexp_like(l_string,'^(WP|AM)\d{2}$'

在一个表达式中同时匹配WP和AM。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章