Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Using PL/SQL, suppose we've declared a nested table type and its instance as follows:

type nested_tab is table of pls_integer;
tab nested_tab;.

We are then able to initialize our nested table as follows:

tab := nested_tab(1, 2, 3);.

Is there something similar we can do to initialize an associative array?

In other words, for the following associate array:

type associative_tab is table of varchar2(100) index by pls_integer;
a_tab associative_tab;

is there a shorter way than this:

a_tab(1) := 'hello';
a_tab(2) := 'world';
a_tab(100) := '100th string';

for intialization?

share|improve this question
I don't think there's a shorter way to do it; if there is, it would probably be here:… – FrustratedWithFormsDesigner Jul 17 '12 at 21:21

1 Answer 1

No - there is no a short-cut syntax to initialize an associative array. Unlike varrays and nested tables associative arrays do not have collection constructors.

Instead you should write your own initializer function. See an example from Declaring Associative Array Constants.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.