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
|
me@myOracle> select * from test1;
COL1 COL2
---------- ----------
1 2
1 1
me@myOracle> select * from test2;
COL1 COL2
---------- ----------
3 1
2 1
me@myOracle> select t1.col1, t2.col2 from test1 t1, test2 t2 where t2.col1=t1.col2;
COL1 COL2
---------- ----------
1 1
me@myOracle> declare
2 cursor l_cur is select t1.rowid test1_rowid, t1.col1,
3 t2.rowid test2_rowid, t2.col2
4 from test1 t1, test2 t2
5 where t2.col1=t1.col2
6 for update of t1.col1, t2.col1;
7 begin
8 for cur_rec in l_cur
9 loop
10 delete test1 where rowid=cur_rec.test1_rowid;
11 delete test2 where rowid=cur_rec.test2_rowid;
12 end loop;
13 commit;
14 end;
15 /
PL/SQL procedure successfully completed.
me@myOracle> select * from test1;
COL1 COL2
---------- ----------
1 1
me@myOracle> select * from test2;
COL1 COL2
---------- ----------
3 1 |