drop table t_country; / create table t_country(country_id number(12),country_name varchar(30)); / drop sequence s_country_id; / create sequence s_country_id increment by 1 start with 1 maxvalue 999999999; create or replace trigger bef_ins_t_country before insert on t_country referencing old as old new as new for each row BEGIN select s_country_id.nextval into :new.country_id from dual; END; / drop table t_city; / create table t_city(city_id number(12),city_name varchar(30)); / drop sequence s_city_id; / create sequence s_city_id increment by 1 start with 1 maxvalue 999999999; / create or replace trigger bef_ins_t_city before insert on t_city referencing old as old new as new for each row BEGIN select s_city_id.nextval into :new.city_id from dual; END bef_ins_t_city; / 执行一下,ok了?
不解?
请赐教~~~~~~
是不是在一个.sql文件中只能创建一个触发器啊?
/
create table t_country(country_id number(12),country_name varchar(30));
/
drop sequence s_country_id;
/
create sequence s_country_id increment by 1 start with 1 maxvalue 999999999;
create or replace trigger bef_ins_t_country before insert on t_country referencing old as old new as new for each row
BEGIN
select s_country_id.nextval into :new.country_id from dual;
END;
/
drop table t_city;
/
create table t_city(city_id number(12),city_name varchar(30));
/
drop sequence s_city_id;
/
create sequence s_city_id increment by 1 start with 1 maxvalue 999999999;
/
create or replace trigger bef_ins_t_city before insert on t_city referencing old as old new as new for each row
BEGIN
select s_city_id.nextval into :new.city_id from dual;
END bef_ins_t_city;
/
执行一下,ok了?
已经OK了,在第一个触发器的END后面加一个/就行了~~~~~~~~~
多谢、小弟初学Oracle 以后还请多多指教~~~~~~
:)
用create or replace用替代.