问题
Is there anyway to create a map data structure in pl/sql.
回答1:
There is the PL/SQL associative array
DECLARE
TYPE salary_tab_t IS TABLE OF NUMBER INDEX BY VARCHAR2(30);
salary_tab salary_tab_t;
BEGIN
salary_tab('JONES') := 10000;
salary_tab('SMITH') := 12000;
salary_tab('BROWN') := 11000;
END;
You can loop through the elements like this:
l_idx := salary_tab.FIRST;
LOOP
EXIT WHEN l_idx IS NULL;
dbms_output.put_line (salary_tab(l_idx));
l_idx := salary_tab.NEXT(l_idx);
END LOOP;
来源:https://stackoverflow.com/questions/2728284/map-data-structure-in-pl-sql-for-storing-key-value-pair