Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: ARRAY in PL/SQL ???
In article <37702A72.D862CF1E_at_sftw.umac.mo>,
d951686_at_sftw.umac.mo wrote:
> Hello,
>
> Is it possible to define an ARRAY that can store differnt data type of
> data.
>
> Such as,
>
> declare
> TYPE myArray IS TABLE of some_description INDEX BY BINARY_INTEGER;
> array myArray;
> begin
> array(1) := 'Hello PL/SQL';
> array(2) := 123;
> array(3) := 456.789;
> end;
>
> Is it possible to implemment this ????
>
> Best regards,
> Eric
>
You can't decleare an array like that, but you can create a record data type such as:
type customer_rectype is record
( cust_id number(5), cust_name varchar2(50), cust_birth_dt date
And then create a table of those records like this:
type customer_recs_tabtype is table of customer_rectype index by binary_integer;
customer_recs customer_recs_tabtype;
Then you can populate the records like this:
So here is the an example procedure:
(cust_id number(5), cust_name varchar2(50), cust_birth_dt date
type customer_recs_tabtype is table of customer_rectype index by
binary_integer;
customer_recs customer_recs_tabtype;
BEGIN
for i in 1..customer_recs.count loop
dbms_output.put_line('*** Record ' || i || ' ***'); dbms_output.put_line('CustID: ' || customer_recs(i).cust_id); dbms_output.put_line('CustName: ' || customer_recs(i).cust_name); dbms_output.put_line('CustBirth: ' || customer_recs (i).cust_birth_dt); dbms_output.put_line(chr(10));
END TEST_ARRAY;
--
Erik
Consultant
Saraswati Systems Corporation - (SSC)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Thu Jun 24 1999 - 09:13:14 CDT