Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Arrays in PL/SQL
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';
Dbms_output.put_line('User ID : '||UsrTab(cnt).user_id); Dbms_output.put_line('User Name: '||UsrTab(cnt).user_name); Cnt:=Cnt+1;
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