2 cədvəlin birləşməsi olan VİEW-ya trigger vasitəsi ilə insert

SYSTEM@valeh> create table emp_list (id number, name varchar2(20));
 SYSTEM@valeh> insert into emp_list values (1,'Valeh');
 SYSTEM@valeh> create table emp_age (age_id number, emp_id number, emp_age number);
 SYSTEM@valeh> create view emp_view as select * from emp_list el,emp_age age where el.id=age.emp_id;
create or replace trigger view_trigger
 instead of insert on emp_view
 referencing new as new old as old
 v_id VARCHAR(20);
 if :new.id is not null then
 insert into emp_list (id,name) values (:new.id,:new.name);
 insert into emp_age (age_id,emp_id,emp_age) values (:new.age_id,:new.emp_id,:new.emp_age)
 returning :new.id into v_id;
 raise_application_error (-20999, 'Cannot create employee without name');
 end if;
SYSTEM@valeh> insert into emp_view values (2,'taleh',2,2,20);

SYSTEM@valeh> select * from emp_view;


Leave a Reply

Please log in using one of these methods to post your comment:

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