PL / SQL触发游标错误

法兰克特

我几乎是触发器的新手。我有这个触发器的问题。我想在projects表中插入一个新城市(projects.plocations),该城市是游标'cur'的定义所选择的城市之一。当我执行时,出现此错误:

12/21 PLS-00103:找到了符号“ =”,而不是以下之一。

翻译: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;
巴特·范德漂移

改变

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

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章