【问题标题】:oracle trigger with errororacle 触发错误
【发布时间】:2018-08-21 09:37:22
【问题描述】:

我是编程新手,不擅长,所以请帮我解决下一个问题:

我有这个触发器:

begin
if (:new.POLUARE LIKE '%W%' 
    OR :new.POLUARE LIKE '%ZA%' 
    OR :new.POLUARE LIKE '%ZD%' 
    OR :new.POLUARE LIKE '%ZG%' 
    OR :new.POLUARE LIKE '%ZJ%') AND SUBSTR(NR_REGISTR,1,1)='A'
`    `:new.INCERCARE:='NEDC';
end if;  
end;

我收到以下错误:

PLS-00103: Encountered the symbol "" when expecting one of the following:
* & - + / at mod remainder rem then <an exponent (**)> and or || multiset

The symbol "then" was substituted for "" to continue.

【问题讨论】:

  • 这些反引号是您原始代码的一部分,还是在您尝试格式化时出现在问题中?
  • IF 需要 THEN。详见手册:docs.oracle.com/database/121/LNPLS/…
  • PL/SQL 使用then 关键字来终止if 条件(if x then y; end if;),而其他一些语言使用括号(if (x) y;)你不需要两者。

标签: oracle plsql database-trigger


【解决方案1】:

尝试使用此代码:

begin
if ( (:new.POLUARE LIKE '%W%' 
         OR :new.POLUARE LIKE '%ZA%' 
         OR :new.POLUARE LIKE '%ZD%' 
         OR :new.POLUARE LIKE '%ZG%' 
         OR :new.POLUARE LIKE '%ZJ%')
      AND SUBSTR(NR_REGISTR,1,1)='A')
then :new.INCERCARE := 'NEDC';
end if;  
end;

我认为您在使用括号封装您的 OR 时遇到了问题。

【讨论】:

  • 感谢您的帮助。我在 SUBSTR (NR_REGISTR, 1.1) 遇到问题,它必须是 SUBSTR (: new.NR_REGISTR, 1.1)。再次感谢您。
猜你喜欢
  • 2011-08-07
  • 1970-01-01
  • 2014-04-07
  • 2014-11-29
  • 2011-09-16
  • 2017-06-10
  • 2018-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多