A Simple Example of 2D Array in PL/SQL
create or replace type Arr1D_Type is table of Number(2);
create or replace type Arr2D_Type is table of Arr1D_Type;
declare
Arr2D Arr2D_Type;
begin
Arr2D := new Arr2D_Type(
Arr1D_Type( 1,2,3,4 ),
Arr1D_Type( 5,6,7,8 ),
Arr1D_Type( 9,10,11,12 ),
Arr1D_Type( 13,14,15,16 )
);
DBMS_OUTPUT.PUT_LINE(' OUTPUT ');
DBMS_OUTPUT.PUT_LINE('----------------');
for x in 1..Arr2D.Count
loop
for y in 1..Arr2D(x).Count
loop
DBMS_OUTPUT.PUT(rpad(Arr2D(x)(y),4));
end loop;
DBMS_OUTPUT.PUT_LINE('');
end loop;
end;
/
OUTPUT
----------------
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
good use of typing
ReplyDeleteTyping ???
DeleteGood example!
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete