If I declare an array such as the one below.
declare
type array_type is table of varchar2(100) index by binary_integer;
component_array array_type;
begin
component_array(12345) := 'One';
component_array(12347) := 'Two';
component_array(12349) := 'Three';
for i in component_array.FIRST .. component_array.LAST
loop
dbms_output.put_line(component_array(i));
end loop;
end;
Is there a way to loop through only the existing binary_integer indeces? For example, if you execute the block above, you'll get an error because the loop iteration is hitting 12346 which of course doesn't exist. Other than the workaround below, is there another way using any type of array method?
declare
type array_type is table of varchar2(100) index by binary_integer;
component_array array_type;
begin
component_array(12345) := 'One';
component_array(12347) := 'Two';
component_array(12349) := 'Three';
for i in component_array.FIRST .. component_array.LAST
loop
begin
dbms_output.put_line(component_array(i));
exception
when NO_DATA_FOUND then
null;
end;
end loop;
end;
Thanks.