Oracle'c COLLECT function triggers creation of a new collection type. Is there a way to disable this behavior ?
here is what is happening ...
check existing user types
select object_name from user_objects where object_type = 'TYPE'
no rows selected.
create user data type with collection VARRAY wrapper type
CREATE OR REPLACE TYPE TEST_T
AS OBJECT (C1 VARCHAR2(20 BYTE), C2 VARCHAR2 (11 Byte));
CREATE OR REPLACE TYPE ARRAY_TEST_T AS VARRAY(200) OF TEST_T;
check types ...
select object_name from user_objects where object_type = 'TYPE'
OBJECT_NAME
------------
TEST_T
ARRAY_TEST_T
2 rows selected.
now this quer开发者_StackOverflowy will trigger creation of a new collection type:
select cast(collect(TEST_T(c1,c2)) AS ARRAY_TEST_T)
from ( select '1.1' as c1, '1.2' as c2 from dual ) ;
check types again ...
select object_name from user_objects where object_type = 'TYPE'
OBJECT_NAME
-----------------------------
TEST_T
SYSTP5Iel7MEkRT2osGnB/YcB4A==
ARRAY_TEST_T
3 rows selected.
Oracle has created new collection type "SYSTP5Iel7MEkRT2osGnB/YcB4A==" with following spec :
CREATE OR REPLACE TYPE "SYSTPzGCo9gclT3WmlUX5SNtEPg==" AS TABLE OF TEST_T
Read http://www.oracle-developer.net/display.php?id=306
I think it will work when you define:
CREATE OR REPLACE TYPE ARRAY_TEST_T AS Table OF TEST_T;
So no varray(200) of ... but table of... .
精彩评论