【问题标题】:PL/SQL Trigger cursor errorPL/SQL 触发游标错误
【发布时间】:2014-09-18 08:45:30
【问题描述】:

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

12/21 PLS-00103:Trovato il simbolo "=" anzichÚ uno dei 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;

【问题讨论】:

标签: plsql triggers oracle10g


【解决方案1】:

改变

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

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

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

【讨论】:

  • 好的。完毕。但它再次显示相同的错误和相同的行。
  • 如果您使用此答案中提供的信息到@Franktrt 下面的行,您能解决您的问题吗?
  • 完成。谢谢你。在下面的行中是 c:=1。它现在没有显示错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-07
  • 1970-01-01
  • 2020-09-04
  • 2023-03-16
  • 2012-02-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多