PL / SQL触发器游标错误

时间:2014-09-18 08:45:31

标签: plsql triggers oracle10g

我几乎不熟悉触发器。这个触发器有问题。我想在项目表中插入一个新的城市(projects.plocations),它是光标'cur'定义所选择的城市之一。 当我执行时,我收到了这个错误:

12/21 PLS-00103:Trovato il simbolo“=”anzichÚunode seguenti。

翻译: 12/21 PLS-00103:在遇到以下任何一种情况时遇到符号“=”:

但是,如果我在没有线条的情况下执行,它就没有错误:

**if (:new.plocation := city) then
c=1;
end if;**

你能告诉我为什么吗?

create or replace trigger tr_projects
before insert on projects
for each row
declare
exc exception;
cursor cur is (
    (select dlocation from dept_locations) minus (select plocation from projects));
city varchar(30);
c number(1):=0;
begin
open cur;
loop
fetch cur into city;
exit when cur%notfound;
if (:new.plocation := city) then
    c=1;
end if;
end loop;
close cur;
if c=0 then
raise exc;
end if;
exception
when exc then
raise_application_error(-20001,'Unknown city');
end;

1 个答案:

答案 0 :(得分:0)

更改

if (:new.plocation := city) then
    c=1;
end if;

if (:new.plocation = city) then
    c := 1;
end if;

:=是赋值运算符,=是比较运算符