-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger_t_loan_emp_backup.sql
More file actions
45 lines (40 loc) · 1.08 KB
/
trigger_t_loan_emp_backup.sql
File metadata and controls
45 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- create table emp(
-- eid number(3) constraint emp_id_pk primary key,
-- ename varchar2(10),
-- loan_ck varchar2(2) default 'N');
-- create table loan(
-- empid number(3) constraint loan_empid_fk references emp(eid),
-- amount number(10),
-- loan_date date default sysdate);
-- create sequence s_eid
-- increment by 1
-- start with 1
-- maxvalue 100;
-- insert into emp(eid, ename)
-- values(s_eid.nextval, '±èÁ¦´Ï');
-- insert into emp(eid, ename)
-- values(s_eid.nextval, '¹ÚÁö¼ö');
-- insert into emp(eid, ename)
-- values(s_eid.nextval, 'È«·ÎÁ¦');
create or replace trigger t_loan_emp_backup
after insert or update of empid or delete on loan
for each row
begin
if inserting then
update emp
set loan_ck = 'Y'
where eid = :new.empid;
elsif deleting then
update emp
set loan_ck = 'N'
where eid = :old.empid;
elsif updating then
update emp
set loan_ck = 'N'
where eid = :old.empid;
update emp
set loan_ck = 'Y'
where eid = :new.empid;
end if;
end;
/