Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Arrays - 2 dimensional?

Re: PL/SQL Arrays - 2 dimensional?

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: 15 Feb 2003 17:11:28 GMT
Message-ID: <b2lsc0$1dr8c7$1@ID-82536.news.dfncis.de>

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

begin
  x:=array_of_array.p;

  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);

    end loop;
    v_i := x.next(v_i);
  end loop;
end;
/   

Hth

Rene Nyffenegger  

-- 
  no sig today
Received on Sat Feb 15 2003 - 11:11:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US