Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Arrays - 2 dimensional?
>
> Take the following:
>
> create or replace package x
> is
> type array is table of varchar2(2000) index by binary_integer;
> procedure p;
> end;
> /
>
> I am looking for a way to define another data type which allows me to
> have an array of arrays if that makes sense.
>
> Possible?
Just nest your types:
set serveroutput on size 1000000
create or replace package array_of_array as type vc_array is table of varchar2(100) index by pls_integer; type vc_array_array is table of vc_array index by pls_integer;
function p return vc_array_array;
end array_of_array;
/
create or replace package body array_of_array as
function p return vc_array_array is
ret vc_array_array;
begin
ret(1)(10) := '10'; ret(2)(15) := '30'; ret(2)( 4) := '8'; ret(3)( 2) := '6'; ret(3)( 9) := '27'; ret(7)( 4) := '28'; ret(6)( 6) := '36'; ret(1)( 8) := '8';
return ret;
end p;
end array_of_array;
/
declare
x array_of_array.vc_array_array; v_i pls_integer; v_j pls_integer;
v_i := x.first;
while v_i is not null loop
v_j := x(v_i).first;
while v_j is not null loop
dbms_output.put_line(v_i || ' x ' || v_j || ' = ' || x(v_i)(v_j)); v_j := x(v_i).next(v_j);
Hth
Rene Nyffenegger
-- no sig todayReceived on Sat Feb 15 2003 - 11:11:28 CST