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 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 99 100 101 102 103 104 105 106 107 108 109 110
| dev001>
dev001> create table p(x int primary key);
Table created.
dev001> create table e(x int primary key, y references p);
Table created.
dev001> create table bp(x int primary key);
Table created.
dev001>
dev001> insert into bp values (0);
1 row created.
dev001> insert into bp values (1);
1 row created.
dev001> insert into bp values (2);
1 row created.
dev001> commit;
Commit complete.
dev001>
dev001> create procedure init
2 as
3 begin
4 execute immediate 'truncate table e';
5 delete p;
6 insert into p select * from bp;
7 insert into e values (3,0);
8 commit;
9 end;
10 /
Procedure created.
dev001> show errors
No errors.
dev001>
dev001>
dev001>
dev001> exec init;
PL/SQL procedure successfully completed.
dev001>
dev001> -- T1
dev001> update e set y=1 where x=3;
1 row updated.
dev001> commit;
Commit complete.
dev001> -- T2
dev001> update e set y=2 where x=3;
1 row updated.
dev001> commit;
Commit complete.
dev001>
dev001> select * from e;
X Y
---------- ----------
3 2
dev001>
dev001>
dev001> exec init;
PL/SQL procedure successfully completed.
dev001>
dev001> -- T2
dev001> update e set y=2 where x=3;
1 row updated.
dev001> commit;
Commit complete.
dev001> -- T1
dev001> update e set y=1 where x=3;
1 row updated.
dev001> commit
2 ;
Commit complete.
dev001> select * from e;
X Y
---------- ----------
3 1 |
Partager