Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle's COLLECT function creates new collection data type with random name

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 query 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
like image 686
Timour Avatar asked Feb 17 '26 17:02

Timour


1 Answers

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... .

like image 105
tuinstoel Avatar answered Feb 20 '26 14:02

tuinstoel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!