0

触发代码 -

CREATE OR REPLACE TRIGGER tib_ms_merchant_group 
BEFORE INSERT 
ON ms_merchant_group FOR EACH ROW DECLARE integrity_error EXCEPTION; 

PRAGMA EXCEPTION_INIT (integrity_error, -20001); 
errno  INTEGER; 
errmsg CHAR(200); 
dummy  INTEGER; 
FOUND  BOOLEAN; 
BEGIN 
  --  Errors handling 
EXCEPTION 
WHEN integrity_error THEN 
  raise_application_error(errno, errmsg); 
END;

错误 -

"PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: 
:= . ( @ % ;
The symbol ";" was substituted for "EXCEPTION" to continue."
4

2 回答 2

0

也许您应该在BEGIN指令之后声明一些内容以使函数执行实际操作?这(可能)是 SQL 语法所要求的。这就是为什么EXCEPTION不能直接放在BEGIN之后的原因

于 2014-12-31T08:47:30.150 回答
0

正如@sanfor 所说,您需要在BEGIN-EXCEPTION块之间放置一些东西。我可以编译触发器 -

SQL> CREATE
  2  OR
  3  replace TRIGGER tib_ms_merchant_group BEFORE
  4  INSERT
  5  ON emp FOR EACH ROW DECLARE integrity_error EXCEPTION;
  6
  7  PRAGMA EXCEPTION_INIT (integrity_error, -20001);
  8  errno  INTEGER;
  9  errmsg CHAR(200);
 10  dummy  INTEGER;
 11  FOUND  BOOLEAN;
 12  BEGIN
 13    NULL;
 14  EXCEPTION
 15  WHEN integrity_error THEN
 16    raise_application_error(errno, errmsg);
 17  END;
 18  /

Trigger created.

SQL> sho err
No errors.
SQL>

只需替换表名并logicBEGIN.

于 2014-12-31T08:58:13.820 回答