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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Arrays in PL/SQL

Re: Arrays in PL/SQL

From: Lando <MarkL_at_quebim.com>
Date: 1997/08/12
Message-ID: <33F0C22E.9B3ECAE4@quebim.com>#1/1

Starting with 7.3.x you can do something similar. Consider the following (simple) example of a table of records:

Declare

  TYPE UsrRecType is Record

    (User_ID             number(10),
     User_Name        varchar2(40));

  TYPE UsrTabType is Table of UsrRecType     index by binary_integer;

  UsrTab      UsrTabType;
  cnt             pls_integer:=0;

Begin

  UsrTab(1).user_id:=10;
  UsrTab(1).user_name:='Max';
  UsrTab(2).user_id:=20;
  UsrTab(2).user_name:='Tanya';

  Cnt:=1;
  While (cnt < 3) loop
    begin
       Dbms_output.put_line('User ID  :      '||UsrTab(cnt).user_id);
       Dbms_output.put_line('User Name:  '||UsrTab(cnt).user_name);
       Cnt:=Cnt+1;

    end;
  end loop;
end;
/

M.Landa

Njål A. Ekern wrote:

> ualwayn_at_usgs.gov wrote:
> >
> > Hi,
> >
> > Can anyone please tell me how to declare and access a
 two-dimensional
> > array in PL/SQL?
>
> You can't.
> You can use several similar arrays.
> You can use array of record-type.
> That's it.
>
> One tip though, since the population of arrays is sparse and the index
>
> can consist of many digits (9? 10?), you may come a long way by
> multiplying some of your values to get an unique index.
> I.e: You want : my_array(m, n):=3
> m and n is number(3)
> You do : my_array(m*1000+n) :=3
>
> Regards,
> Njål
>
> >
> > Any help will be appreciated.
> >
> > Thanks,
> >
> > Una.
> >
> > -------------------==== Posted via Deja News

 ====-----------------------

> > http://www.dejanews.com/ Search, Read, Post to Usenet
>
> --
> Njål A. Ekern
> n.a.ekern_at_usit.uio.no
Received on Tue Aug 12 1997 - 00:00:00 CDT

Original text of this message

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