【发布时间】:2020-09-04 17:38:26
【问题描述】:
当我运行这段代码时,我遇到了这个错误:
PLS-00103:在预期以下情况之一时遇到符号“IS”:
:= . ( @ % ; not null range default character.
我认为声明部分有问题,但相同的声明在 row-lvl 触发器中有效,所以我很困惑这在复合触发器中是否允许。我找不到例子,所以我在这里问你。
create or replace trigger ivan_moving
for update of country on clients
compound trigger
declare
n_country clients.country%type;
min_date clients.bday%type;
cursor ivans is select* from clients where fname like 'Ivan%' and Bday > (select min(Bday) from clients where fname like 'Ivan%');
client_ivan ivans%rowtype;
before statement is
min_date = select Bday from clients where fname like 'Ivan%' and Bday = (select min(Bday) from clients where fname like 'Ivan%');
end before statement;
after each row is
begin
if :OLD.country <> :NEW.country and fname = 'Ivan%' and bday = min_date
n_country := :new.country;
end if;
end after each row;
after statement is
begin
open ivans;
loop
fetch ivans into client_ivan;
exit when ivans%notfound;
update clients set country = n_country where id = client_ivan.id;
end loop;
close ivans;
end after statement;
end ivan_moving;
/
【问题讨论】:
标签: oracle plsql oracle11g triggers database-cursor