首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

PLS-00103: Encountered the symbol WHEN when expecting one of the following

2014-01-28 
触发器语句如下: create or replace trigger count_trigger before insert or update or delete on count b

触发器语句如下:
create or replace trigger count_trigger
before insert or update or delete
on count

begin
insert into count_log(
who,when)
values(
user,sysdate);
end;
报错:
Compilation errors for TRIGGER TEST.COUNT_TRIGGER

Error: PLS-00103: Encountered the symbol WHEN when expecting one of the following 

  <an identifier> <a double-quoted delimited-identifier>
The symbol " <an identifier> was inserted before "WHEN" to continue.
Line: 7
Text: who,when)

我单独测试了一次insert into count_log(who,when) values(user,sysdate); 是可以实现的~  有人可以指点一下报错原因么 ?

------解决方法--------------------------------------------------------
凡是有when之类的都需要使用动态sql



immediate execute sql;
------解决方法--------------------------------------------------------
将字段名加双引号试试
insert into count_log(
"who","when")
values(
user,sysdate);
------解决方法--------------------------------------------------------
字段名、变量名应该避免和保留字(reserved word)冲突。
when 是PLSql 的保留字,你的字段名也是 when,冲突了。

        

热点排行