在pl/sql没有Array数据这个概念,但是可以用表数据库类型来模拟数组:
实例:
主要部分:
type emp_ssn_array is table of varchar2(20) index by BINARY_INTEGER; -- 定义emp_ssn_array为数据表类型
best_employees emp_ssn_array;-- 实例化
数据输入:
best_employees(1) := '宝坻';best_employees(2) := '北辰';best_employees(3) := '大港';
best_employees(4) := '东丽';best_employees(5) := '汉沽';
best_employees(6) := '和平';best_employees(7) := '河北';best_employees(8) := '河东';
best_employees(9) := '河西';best_employees(10) := '红桥';
best_employees(11) := '蓟县';best_employees(12) := '津南';best_employees(13) := '静海';
best_employees(14) := '南开';best_employees(15) := '宁河';
best_employees(16) := '塘沽';best_employees(17) := '武清';best_employees(18) := '西青';
取数据:
for i in 1 .. best_employees.count loop
if instr(v_str1,best_employees(i)) > 0 then
v_str := best_employees(i);
exit;
end if;
end loop;
这样使用起来和一维数组没什么区别了.
多维数据则复杂点可以参考: