Oracle SQL自动增加PLS-00103

时间:2013-04-11 22:22:05

标签: sql oracle

当我运行此SQL时:

CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON FITNESS_BMR
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT t1_seq.nextval INTO :NEW.ID FROM dual;
END;

我收到此错误:

"Error at line 7: PLS-00103: Encountered the symbol ""CREATE""",""

有人知道为什么吗?

1 个答案:

答案 0 :(得分:0)

我在 an SQL fiddle 中使用了您的代码,我的错误略有不同:

ORA-00900: invalid SQL statement

我将您的代码更改为仅删除dual后面的分号,我可以创建没有错误。该表必须存在,但我认为它已经存在! ;)

create table FITNESS_BMR ( a number(2) );

CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON FITNESS_BMR
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT t1_seq.nextval INTO :NEW.ID FROM dual
END;