Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A PL/SQL question 1

Status
Not open for further replies.

Strife

Programmer
Aug 7, 2001
10
US
Hi all,

I would like to know how to declare an array like myvar(100,50) so it can be referrenced in code like:

declare
temp number;
myvar of type ?
begin
.. do some stuff
for i in 1..100 loop
temp := myvar(i,10);
end loop;
.. do more stuff
exception
end;

I am aware of this type but this is no good:

TYPE TabNames IS TABLE OF VARCHAR2(30)
INDEX BY BINARY_INTEGER;
tab_name TabNames;

I want an extra nested level, is this possible, can anyone help me?
Thanks
David
 
I don't think you can do this directly. About the closest I think you can come is to create a 50-field record, and then make a table of these records.

The code would look something like:

declare
TYPE table_element_type IS RECORD(field1 number, field2 VARCHAR2(25),....,field50 date);
TYPE table_type IS TABLE OF table_element_type INDEX BY BINARY_INTEGER;
temp number;
myvar table_type

BEGIN
.. do some stuff
for i in 1..100 loop
temp := myvar(i.field10);
end loop;
.. do more stuff
exception
...
end;

Granted, this isn't exactly what you wanted, but I think it's as close as you're going to get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top