SET ECHO ON SET SERVEROUTPUT ON SET ARRAYSIZE 1 -- -- plsql08.txt -- -- Simple PL/SQL demo of associative array DECLARE -- Declare a TYPE which may be used to hold key-value pairs -- aka index-by table -- aka associative array TYPE dict_type IS TABLE OF VARCHAR2(64) INDEX BY VARCHAR2(64); -- Notice key words "TABLE ... INDEX BY" d1 dict_type; -- d1 will be the actual associative array BEGIN -- Fill the associative array d1('X$KSLLT') := 'Synonym for X_$KSLLT'; d1('X$KSPPI') := 'Synonym for X_$KSPPI'; d1('X$KSPPSV') := 'Synonym for X_$KSPPSV'; d1('X$KSQST') := 'Synonym for X_$KSQST'; -- get a value using a key dbms_output.put_line ( d1('X$KSPPSV') ); -- Replace a value in the array d1('X$KSLLT') := 'Synonym for X_$KSLLT but not Bikle'; dbms_output.put_line ( d1('X$KSLLT') ); -- Make use of keywords FIRST and LAST dbms_output.put_line ( d1.FIRST ); -- get a key dbms_output.put_line ( d1.LAST ); -- get a key dbms_output.put_line ( d1(d1.FIRST) ); -- get a value dbms_output.put_line ( d1(d1.LAST) ); -- get a value END; / -- End of demo