【发布时间】:2013-09-27 15:37:55
【问题描述】:
Oracle pl/sql 中是否有一种方法可以创建像 java Hashmap 这样的数据结构,它可以将记录类型作为值,将字符串作为索引。
例如;
type emp_rec_type is record (emp_id number,emp_salary number);
emp_rec emp_rec_type;
type emp_assoc_array is table of emp_rec_type indexed by varchar2(30);
emp_map emp_assoc_array;
我希望能够做到以下几点
emp_rec.emp_id := 1;
emp_rec.salary := 1000;
emp_map('Rohan') := emp_rec;
这可以实现吗? 我不能使用嵌套表,因为我只能按整数索引它。 使用关联数组,我不能使用对象类型作为属性。
还想在不必创建对象或模式数据类型的情况下执行此操作。 能不能给点建议?
【问题讨论】:
-
您的示例中已经有了答案。小修正。不是
indexed by,而是index by,你很高兴。