Reputation: 1398
I am trying to create an associative array in Oracle, when I create a nested table, it works fine:
CREATE OR REPLACE TYPE TRNG_BOOK_AUTHORS_TAB
AS TABLE OF VARCHAR2(500);
But when I add the index I get errors:
CREATE OR REPLACE TYPE TRNG_BOOK_AUTHORS_TAB
AS TABLE OF VARCHAR2(500) INDEX BY PLS_INTEGER;
What do I have wrong?
Upvotes: 3
Views: 524
Reputation: 191275
You are creating a schema type; those can be nested tables or varying arrays (varrays), but not associative arrays.
From the documentation for the create type
statement:
A standalone collection type that you create with the
CREATE TYPE
statement differs from a collection type that you define with the keywordTYPE
in a PL/SQL block or package. For information about the latter, see "Collection Variable Declaration".With the
CREATE TYPE
statement, you can create nested table andVARRAY
types, but not associative arrays. In a PL/SQL block or package, you can define all three collection types.
Upvotes: 3