We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Two dimensional array in oracle

ajexpert
ajexpert asked
on
Medium Priority
2,795 Views
Last Modified: 2013-12-18
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.
&.
&.
Comment
Watch Question

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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.
 
Sean StuberDatabase Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012
Commented:
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;
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.