读书人

PLS-00103: Encountered the symbol W

发布时间: 2014-01-28 21:26:59 作者: rapoo

触发器语句如下:
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,冲突了。

        

读书人网 >oracle

热点推荐