The following code works but it seems that I have to initialize a 2D table (arr2D) using a constructor. In this case I'm passing 2 arr1D objects to the constructor but what if I don't know the exact number of items ahead of time. The types should be defined at a schema level ( I need to work with sql rather than plsql types)
CREATE OR REPLACE TYPE tt_v2_255_arr IS TABLE OF VARCHAR2(255);
CREATE OR REPLACE TYPE tt_v2_255_arr_arr IS TABLE OF tt_v2_255_arr;
declare
arr2d tt_v2_255_arr_arr;
arr1d tt_v2_255_arr := tt_v2_255_arr();
begin
arr1d.extend(2);
arr2d := tt_v2_255_arr_arr( arr1d, arr1d );
arr2d(1)(1) := 'A';
arr2d(1)(2) := 'B';
arr2d(2)(1) := '1';
arr2d(2)(2) := '2';
dbms_output.put_line( arr2d(1)(2) );
exception when others then
dbms_output.put_line( sqlerrm );
end;
/
So, how to initialize arr2D with an arbitrary numbers of objects?
For example, INIT function is supposed to create NUM_TIMES instances of arr1D and initialize arr2D with it.
arr2d := tt_v2_255_arr_arr( INIT(arr1d, NUM_TIMES ));