谁能举例说明如何在这种情况下显示两个不同的嵌套表?
CREATE TYPE varchar_ot AS OBJECT (varchar_field VARCHAR2(40));
CREATE TYPE number_ot AS OBJECT (number_field NUMBER);
CREATE TYPE varchar_ntt AS TABLE OF varchar_ot;
CREATE TYPE number_ntt AS TABLE OF number_ot;
CREATE TABLE collections
(
col_id NUMBER
, col_varchar varchar_ntt
, col_number number_ntt
)
NESTED TABLE col_varchar STORE AS col_varchar_nt
NESTED TABLE col_number STORE AS col_number_nt
;
-- table COLLECTIONS created.
INSERT INTO collections VALUES
(
1
, (varchar_ntt(varchar_ot('a'), varchar_ot('b')))
, (number_ntt (number_ot(11), number_ot(22)))
);
-- 1 rows inserted.
INSERT INTO collections VALUES
(
2
, (varchar_ntt(varchar_ot('c'), varchar_ot('d')))
, (number_ntt (number_ot(33), number_ot(44)))
);
-- 1 rows inserted.
SELECT col_id, varchar_field, number_field
FROM collections, TABLE(collections.col_varchar), TABLE(collections.col_number)
ORDER BY
3, 2, 1
;
COL_ID VARCHAR_FIELD NUMBER_FIELD
1 a 11
1 b 11
1 a 22
1 b 22
2 c 33
2 d 33
2 c 44
2 d 44
声明一个对象类型的表,其中对象包含两个嵌套表
CREATE TYPE a_varchar_ntt AS TABLE OF VARCHAR2(30);
CREATE TYPE a_number_ntt AS TABLE OF NUMBER;
CREATE TYPE var_num_ot AS OBJECT
(
col_var a_varchar_ntt
, col_num a_number_ntt
);
TYPE var_num_ntt AS TABLE OF var_num_ot;
/*
Error report:
Unknown Command
*/
如果这不是一个练习,那么您将走错方向,使事情变得过于复杂。