ORA-25028:常规触发器主体无法以关键字COMPOUND启动

时间:2015-04-22 17:06:05

标签: oracle plsql

我为我创建的触发器收到了变异错误。因此,我改变了触发器以使用复合触发器。我有一个复合触发器如下:

CREATE OR REPLACE TRIGGER trig_chpt_update
AFTER UPDATE ON task_status
COMPOUND TRIGGER
/* Declaration Section */
task_id number(15);
ckpt_id number(15);
count_of_ckpt number(15);
record number(15);
ckpt_completed number(15):=0;
total_ckpt number(15):=0;

CURSOR cur_task_ckpt IS
SELECT c.taskid, c.ckpt_id, ts.status FROM checkpoint c INNER JOIN   
task_status ts ON c.ckpt_id=ts.ckpt_id;

AFTER EACH ROW IS
BEGIN
/* Get taskid of the checkpoint status being updated */
SELECT taskid INTO task_id FROM checkpoint WHERE ckpt_id=:new.ckpt_id;
END AFTER EACH ROW;

AFTER EACH STATEMENT IS
BEGIN
/* Get number of checkpoints for the task */
--SELECT COUNT(*) INTO count_of_ckpt FROM checkpoint WHERE taskid=task_id;

/* Checking the assumption */
OPEN cur_task_ckpt;
FOR record IN cur_task_ckpt
LOOP
  IF record.taskid=task_id THEN
     total_ckpt:=total_ckpt+1;
     IF record.status=1 THEN
        ckpt_completed:=ckpt_completed+1;
     END IF;
  END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE(ckpt_completed||' of '||total_ckpt||' checkpoints associated with Task ID '||task_id||'have been completed.');
 CLOSE cur_task_ckpt;
END AFTER STATEMENT;

END trig_chpt_update;

但是当我执行它时,我收到错误ORA-25028: regular trigger body can not start with keyword COMPOUND。请告诉我哪里出错了。

1 个答案:

答案 0 :(得分:2)

我相信你需要改变

CREATE OR REPLACE TRIGGER trig_chpt_update
AFTER UPDATE ON task_status
COMPOUND TRIGGER

CREATE OR REPLACE TRIGGER trig_chpt_update
FOR UPDATE [OF field] ON task_status
COMPOUND TRIGGER

修改

验证后,我确认正确的语法是

CREATE OR REPLACE TRIGGER compound_trigger_name
FOR [INSERT|DELETE|UPDATE] [OF column] ON table
COMPOUND TRIGGER

请注意,Coumpound触发器是在Oracle 11g中引入的。