Isa*_*man 5 oracle plsql array
在 PL/SQL 中,假设我有一些定义如下的关联数组:
declare
type a_arr_t is table of PLS_INTEGER index by PLS_INTEGER;
a_arr a_arr_t;
Run Code Online (Sandbox Code Playgroud)
然后,我按如下方式稀疏地填充数组:
begin
a_arr(1) := 2;
a_arr(10) := 4;
a_arr(100) := 6;
end;
Run Code Online (Sandbox Code Playgroud)
是否有一些运算符或函数可以为我提供数组的索引,(1,10,100)
作为某种集合,例如indices of
在forall
语句中?
是否有一些运算符或函数可以给我数组的索引
不,您必须遍历关联数组:
declare
type a_arr_t is table of PLS_INTEGER index by PLS_INTEGER;
type keys_t is table of PLS_INTEGER;
a_arr a_arr_t;
keys_ keys_t := keys_t();
l_index integer;
begin
a_arr(1) := 2;
a_arr(10) := 4;
a_arr(100) := 6;
l_index := a_arr.first;
while (l_index is not null)
loop
keys_.extend();
keys_(keys_.count):=l_index;
dbms_output.put_line(keys_(keys_.count));
l_index := a_arr.next(l_index);
end loop;
end;
/
/*
1
10
100
*/
Run Code Online (Sandbox Code Playgroud)