Map data structure in pl/sql for storing key value pair?

萝らか妹 提交于 2020-11-30 12:15:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!