日期:2014-05-17  浏览次数:20801 次

新建了个插入触发器,在插入的时候出现“通信通道的文件结束”错误
想实现ID自增,新建了sequence、trigger,如下:
SQL code
create sequence t_skyquality_seq
minvalue 1
NOMAXVALUE 
increment by 1
start with 1
NOCYCLE
cache 20;

CREATE or replace TRIGGER t_skyquality_trigger 
BEFORE INSERT ON t_skyquality FOR EACH ROW WHEN (new.id is null)
begin
        select t_skyquality_seq.nextval into: new.id from dual;
end;

在随便插入个数据时,就出现了“通信通道的文件结束”错误,最后pl/sql死掉。。

------解决方案--------------------
探讨
怎么“直接用t_skyquality_seq.nextval 替换new.id”

------解决方案--------------------
select t_skyquality_seq.nextval into: new.id from dual;
这句改成
select t_skyquality_seq.nextval into :new.id from dual;
注意冒号位置
------解决方案--------------------
探讨
select t_skyquality_seq.nextval into: new.id from dual;
这句改成
select t_skyquality_seq.nextval into :new.id from dual;
注意冒号位置