Task

The goal is to create an associative array (also known as a dictionary, map, or hash).



Related tasks:

 Associative arrays/Iteration
 Hash from two arrays


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


 
--#SET TERMINATOR @
 
SET SERVEROUTPUT ON @
 
BEGIN
 DECLARE TYPE ASSOC_ARRAY AS VARCHAR(20) ARRAY [VARCHAR(20)];
 DECLARE HASH ASSOC_ARRAY;
 SET HASH['key1'] = 'val1';
 SET HASH['key-2'] = 2;
 SET HASH['three'] = -238.83;
 SET HASH[4] = 'val3';
 
 CALL DBMS_OUTPUT.PUT_LINE(HASH['key1']);
 CALL DBMS_OUTPUT.PUT_LINE(HASH['key-2']);
 CALL DBMS_OUTPUT.PUT_LINE(HASH['three']);
 CALL DBMS_OUTPUT.PUT_LINE(HASH[4]);
 CALL DBMS_OUTPUT.PUT_LINE(HASH['5']);
END@
 