GlukOza |
Мне надо обновить fallouts внутри T_trunk_rec. А точнее - обналить. |
SQL> DROP TABLE temp
2 /
Table dropped.
SQL> DROP TYPE net_rec
2 /
Type dropped.
SQL> DROP TYPE t_trunks
2 /
Type dropped.
SQL> DROP TYPE T_trunk_rec
2 /
Type dropped.
SQL> DROP TYPE t_fallouts
2 /
Type dropped.
SQL> CREATE OR REPLACE
2 type T_fallout is object (
3 code varchar2(100),
4 msg varchar2(512)
5 );
6 /
Type created.
SQL> CREATE OR REPLACE type t_fallouts is table of T_fallout;
2 /
Type created.
SQL> CREATE OR REPLACE
2 type T_trunk_rec is object (
3 address varchar2(36),
4 fallouts t_fallouts
5 );
6 /
Type created.
SQL> CREATE OR REPLACE type t_trunks is table of T_trunk_rec;
2 /
Type created.
SQL> CREATE OR REPLACE
2 type net_rec is object (
3 name varchar2(10),
4 trunks T_trunks);
5 /
Type created.
SQL> CREATE TABLE temp
2 OF NET_REC
3 OBJECT IDENTIFIER IS SYSTEM GENERATED
4 NESTED TABLE trunks STORE AS trunks_tab
5 (NESTED TABLE fallouts STORE AS fallouts_tab)
6 /
Table created.
SQL> INSERT
2 INTO temp
3 VALUES(
4 'GlukOza',
5 T_trunks(
6 T_trunk_rec(
7 'Visitor from the future',
8 t_fallouts(
9 T_fallout(
10 'R',
11 'Code red'
12 ),
13 T_fallout(
14 'B',
15 'Code blue'
16 )
17 )
18 ),
19 T_trunk_rec(
20 'Visitor from the past',
21 t_fallouts(
22 T_fallout(
23 'R',
24 'Code red'
25 ),
26 T_fallout(
27 'B',
28 'Code blue'
29 )
30 )
31 )
32 )
33 )
34 /
1 row created.
SQL> INSERT
2 INTO temp
3 VALUES(
4 'GlukOza',
5 T_trunks(
6 T_trunk_rec(
7 'Visitor from the future',
8 t_fallouts(
9 T_fallout(
10 'R',
11 'Code red'
12 ),
13 T_fallout(
14 'B',
15 'Code blue'
16 )
17 )
18 ),
19 T_trunk_rec(
20 'Visitor from the past',
21 t_fallouts(
22 T_fallout(
23 'R',
24 'Code red'
25 ),
26 T_fallout(
27 'B',
28 'Code blue'
29 )
30 )
31 )
32 )
33 )
34 /
1 row created.
SQL> COMMIT
2 /
Commit complete.
SQL> SELECT *
2 FROM temp
3 /
NAME
----------
TRUNKS(ADDRESS, FALLOUTS(CODE, MSG))
--------------------------------------------------------------------------------
GlukOza
T_TRUNKS(T_TRUNK_REC('Visitor from the future', T_FALLOUTS(T_FALLOUT('R', 'Code
red'), T_FALLOUT('B', 'Code blue'))), T_TRUNK_REC('Visitor from the past', T_FAL
LOUTS(T_FALLOUT('R', 'Code red'), T_FALLOUT('B', 'Code blue'))))
GlukOza
T_TRUNKS(T_TRUNK_REC('Visitor from the future', T_FALLOUTS(T_FALLOUT('R', 'Code
red'), T_FALLOUT('B', 'Code blue'))), T_TRUNK_REC('Visitor from the past', T_FAL
LOUTS(T_FALLOUT('R', 'Code red'), T_FALLOUT('B', 'Code blue'))))
NAME
----------
TRUNKS(ADDRESS, FALLOUTS(CODE, MSG))
--------------------------------------------------------------------------------
SQL> UPDATE temp t1
2 SET trunks = CAST(
3 MULTISET(
4 SELECT T_trunk_rec(t3.address,null)
5 FROM temp t2,
6 TABLE(t2.trunks) t3
7 WHERE t2.rowid = t1.rowid
8 )
9 AS t_trunks
10 )
11 /
2 rows updated.
SQL> SELECT *
2 FROM temp
3 /
NAME
----------
TRUNKS(ADDRESS, FALLOUTS(CODE, MSG))
--------------------------------------------------------------------------------
GlukOza
T_TRUNKS(T_TRUNK_REC('Visitor from the future', NULL), T_TRUNK_REC('Visitor from
the past', NULL))
GlukOza
T_TRUNKS(T_TRUNK_REC('Visitor from the future', NULL), T_TRUNK_REC('Visitor from
the past', NULL))
SQL> ROLLBACK
2 /
Rollback complete.
SQL>
SY.