example for create sequence and trigger in oracle

create table test_b(
u_id integer not null primary key,
u_name varchar(30) not null
)

CREATE SEQUENCE test_b_seq
MINVALUE 1
MAXVALUE 9999999999
START WITH 1
INCREMENT BY 1
CACHE 100;

create or replace TRIGGER trigger_airports
BEFORE INSERT ON airports
FOR EACH ROW
BEGIN
SELECT airport_seq_id.nextval
INTO :new.u_id
FROM dual;
END;

insert into test_b(u_name)values(‘bapu2’);

create or replace TRIGGER test_after_insert AFTER INSERT ON test_b
FOR EACH ROW
BEGIN
insert into test_emp_backup values (:new.u_id, :new.u_name);
END;

select * from test_b;

select * from test_emp_backup;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s