触发代码 -
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."
答案 0 :(得分:0)
可能你应该在 BEGIN 指令之后声明一些内容,以使该函数做一些实际的事情?这可能是(可能)SQL语法所要求的。这就是 BEGIN 之后 EXCEPTION 无法直接放置的原因
答案 1 :(得分: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>
只需替换表名,然后在logic
之后添加所需的触发器BEGIN
。