About
An associative array (also called an index-by table) is a map structure (set of key-value pair) implemented with the “table of index by” keyword
Articles Related
Syntax
TYPE table_of_type IS TABLE OF VARCHAR2(30) ; -- default indexed by integer -- List of Called a Nested table
Characteristic
- Each key is unique
- The key can be either an integer or a string.
Example
set serveroutput on;
DECLARE
TYPE filter_map_type IS TABLE OF VARCHAR2(30) INDEX BY VARCHAR2(30);
filter_map filter_map_type;
key_map VARCHAR2(30);
BEGIN
filter_map('Hello Key') := 'Hello Value';
filter_map('Hello Key 2') := 'Hello Value 2';
filter_map('Hello Key') := 'Hello Value 3';
key_map := filter_map.FIRST;
WHILE key_map IS NOT NULL LOOP
DBMS_OUTPUT.Put_Line('element(' || key_map || '): ' || filter_map(key_map));
key_map := filter_map.NEXT(key_map);
END LOOP;
END;
/
PL/SQL procedure successfully completed.
element(Hello Key): Hello Value 3
element(Hello Key 2): Hello Value 2