对于一个作业,我正在尝试使用Oracle SQL对其PK进行PK触发器的级联更新。我不能在FK中使用级联更新。
下面是我的代码,它会产生相应的错误:
CREATE or REPLACE trigger TR_PRODNO_FK_UPDATE
/* trigger executes BEFORE
an UPDATE of prodNo on the Product table */
before update of prodNo on tbProduct
/* trigger executes for each ROW */
for each row
/* begins a PL/SQL Block */
begin
/* update prodNo on tbProduct */
UPDATE tbProduct a
SET a.prodNo = :new.prodNo
WHERE :old.prodNo = a.prodNo;
/* update the prodNo on tbComponent */
UPDATE tbComponent b
SET b.prodNo = :new.prodNo
WHERE :old.prodNo = b.prodNo;
/* send message to output */
dbms_output.put_line (
'*** Related rows in the
PRODUCT and COMPONENT table updated - TR_PRODNO_FK_UPDATE trigger');
end TR_PRODNO_FK_UPDATE;
/
UPDATE tbProduct
SET prodNo = '104'
WHERE prodNo = '100';
这是怎么回事?有什么想法吗?