- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
CREATE TABLE "A"
( "ID" NUMBER,
"A" NUMBER,
"B" VARCHAR2(20),
CONSTRAINT "A_PK" PRIMARY KEY ("ID") ENABLE
)
/
CREATE OR REPLACE TRIGGER "A_2"
AFTER
insert or update on "A"
for each row
begin
mut_table.bef_tr(:NEW.ID,:NEW.A);
end;
/
ALTER TRIGGER "A_2" ENABLE
/
CREATE OR REPLACE TRIGGER "A_3"
AFTER
insert on "A"
declare
b number;
begin
mut_table.aft_tr;
end;
/
ALTER TRIGGER "A_3" ENABLE
/
CREATE OR REPLACE TRIGGER "A_AT"
BEFORE
insert or update on "A"
for each row
declare
v number;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
:NEW.A:=:NEW.A+1;
:NEW.B:='!!!!!!!!!!';
commit;
end;
/
ALTER TRIGGER "A_AT" DISABLE
/
CREATE OR REPLACE TRIGGER "A_I_S"
BEFORE
insert or update on "A"
begin
mut_table.set_initial_state;
end;
/
ALTER TRIGGER "A_I_S" ENABLE
/
CREATE OR REPLACE TRIGGER "A_T1"
BEFORE
insert or update on "A"
for each row
begin
update A set
A = :NEW.A+1,
B = 'was incremented'
where A = :NEW.A;
end;
/
ALTER TRIGGER "A_T1" DISABLE
/
CREATE OR REPLACE TRIGGER "BI_A"
before insert on "A"
for each row
begin
if :NEW."ID" is null then
select "A_SEQ".nextval into :NEW."ID" from dual;
end if;
end;
/
ALTER TRIGGER "BI_A" ENABLE
/
create or replace package MUT_TABLE as
procedure set_initial_state;
procedure bef_tr(ID number,A NUMBER);
procedure aft_tr;
kikis 14.12.2011 11:02 # +1
SmackMyBitchUp 14.12.2011 13:55 # +4