[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2713
  • Last Modified:

Two dimensional array in oracle

How do I implement a two dimensional array in PL/SQL.
Please note that I do not know the upper bound and I dont want to use varray for the same reason.
Is there anyway I can define a record type, add elements to the record and loop the collection when required?
All I want to implement in PL/SQL, and all TYPE OBJECTS should be declared in PL/SQL block only.
 I will store this kind of data into array.  I will populate the year (1st dimension) and the units (2nd dimension) based on the calculated parameters
2004,1
2004,2
2004,3
2005,1
2005,2
2005,3
2005,4

Example to accomplish above will be real good.
&.
&.
0
ajexpert
Asked:
ajexpert
2 Solutions
 
mohammadzahidCommented:
Please goto this url for answer to your question.

http://www.oracle.com/technology/oramag/oracle/06-jan/o16plsql.html

Let me know if you have any questions.

0
 
ajexpertAuthor Commented:
Nope,
I have already seen this URL before posting question.
The way its described is in bit convoluted manner.  The I assume there is simpler way of doing this.
 
0
 
sdstuberCommented:
an array of arrays is the closest thing you're going to get in pl/sql to a 2-dimensional array.

However, for your data,  it looks like a one dimensional array of a 2 field record type might be sufficient


 TYPE aj_rec IS RECORD(
       year   INTEGER,
       units  INTEGER
    );

TYPE aj_tab IS TABLE OF aj_rec INDEX BY BINARY_INTEGER;
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now