Which of the following is the correct syntax of Associative array of number?

Options
- TYPE numbers_aat IS NUMBER;
- TYPE numbers_aat IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
- TYPE numbers_aat IS TABLE;
- TYPE numbers_aat IS TABLE INDEX BY PLS_INTEGER;


CORRECT ANSWER : TYPE numbers_aat IS TABLE OF NUMBER INDEX BY PLS_INTEGER;

Discussion Board
Associative array

A PL/SQL associative array is a collection type that associates a unique key with a value. An associative array has the following characteristics:
- An associative array type must be defined before array variables of that array type can be declared. Data manipulation occurs in the array variable.
- The array does not need to be initialized; simply assign values to array elements.
- There is no defined limit on the number of elements in the array; it grows dynamically as elements are added.
- The array can be sparse; there can be gaps in the assignment of values to keys.
- An attempt to reference an array element that has not been assigned a value results in an exception.
- Use the TYPE IS TABLE OF statement to define an associative array type.

Syntax:

>>-TYPE--assoctype--IS TABLE OF----datatype--------------------->

>--INDEX BY--+-BINARY_INTEGER--------------+-------------------><
+-PLS_INTEGER-----------------+
'-VARCHAR2--(--n--+------+--)-'
+-BYTE-+
'-CHAR-'

where,

- TYPE assoctype specifies an identifer for the array type.
- Datatype specifies a supported data type, such as VARCHAR2, NUMBER, RECORD, VARRAY, or associative array type. The %TYPE attribute and the %ROWTYPE attribute are also supported.
- INDEX BY specifies that the associative array is to be indexed by one of the data types introduced by this clause.
- BINARY INTEGER and PLS_INTEGER are Integer numeric data.

VARCHAR2 (n[BYTE|CHAR]) : A variable-length character string of maximum length n code units, which may range from 1 to 32 672 BYTE or from 1 to 8 168 CHAR.

Prajakta Pandit 02-20-2017 02:05 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement