You can use SELECT my_record_type(column_value) BULK COLLECT INTO v_table from table(v_hash). But in order to use this, you will have to create my_hash_type outside the function (either as a rack of type OR in the package specification so that it is visible to SQL Engine), otherwise you will get a PLS-00642: local collection types not allowed in SQL statements.
CREATE OR REPLACE TYPE my_hash_type is table OF VARCHAR2(10);
/
set serveroutput on
declare
--type my_hash_type is table OF VARCHAR2(10);
v_hash my_hash_type := my_hash_type();
v_table my_table_type;
i NUMBER;
begin
null ;
for n in 60..75 loop
V_hash.extend(1);
V_hash(v_hash.count) := chr(n) ;
end loop ;
select my_record_type(column_value)
bulk collect into v_table
from table(v_hash) ;
for n in 1..v_table.count loop
dbms_output.put_line( n || ':>' || v_table(n).name);
end loop ;
--PLS-00642: local collection types not allowed in SQL statements
end ;
1:><
2:>=
3:>>
4:>?
5:>@
6:>A
7:>B
8:>C
9:>D
10:>E
11:>F
12:>G
13:>H
14:>I
15:>J
16:>K
look here and here for a few more examples and whatnot
( # hundreths )
pl/sql context switch (as described above)
44
42
43
42
loop fill (with type defined outside of block)
18
18
18
18
loop fill (with type defined within block)
23
22
24
22
( :
set serveroutput on
declare
v_hash my_hash_type := my_hash_type();
v_table my_table_type;
i NUMBER;
time_before BINARY_INTEGER;
time_after BINARY_INTEGER;
begin
time_before := DBMS_UTILITY.GET_TIME;
for n in 0..15000 loop
V_hash.extend(1);
V_hash(v_hash.count) := my_record_type(n) ;
end loop ;
select my_record_type(column_value)
bulk collect into v_table
from table(v_hash) ;
time_after := DBMS_UTILITY.GET_TIME;
DBMS_OUTPUT.PUT_LINE (time_after - time_before);
end ;
/
, 50% , - ( -, , , , ).
"" , , TREAT, , /, ( Varray/Assoc. Array - , !)