确实是经常有人问 第一步:创建SEQUENCE create sequence s_country_id increment by 1 start with 1 maxvalue 999999999; 第二步:创建一个基于该表的before insert 触发器,在触发器中使用该SEQUENCE create or replace trigger bef_ins_t_country_define before insert on t_country_define referencing old as old new as new for each row begin new.country_id=s_country_id.nextval; end;
执行时,trigger出现“无效的触发器类型”!到底怎么回事!!!!
--触发器无效 create or replace trigger bef_ins_t_country_define before insert on t_country_define referencing old as old new as new for each row begin :new.country_id:=s_country_id.nextval; end; /
第一步:创建SEQUENCE
create sequence s_country_id increment by 1 start with 1 maxvalue 999999999;
第二步:创建一个基于该表的before insert 触发器,在触发器中使用该SEQUENCE
create or replace trigger bef_ins_t_country_define
before insert on t_country_define
referencing old as old new as new for each row
begin
new.country_id=s_country_id.nextval;
end;
create or replace trigger bef_ins_t_country_define
before insert on t_country_define
referencing old as old new as new for each row
begin
:new.country_id:=s_country_id.nextval;
end;
/