Oracle PL/SQL - Associative arrays INDEX BY BINARY_INTEGER


The following code uses a FOR loop with the associative arrays INDEX BY BINARY_INTEGER.


SQL> declare-- from   w  w w .  j  av  a2  s .co m
  2       type dept_rty is record(deptNo number, extra_tx VARCHAR2(2000));
  3       type dept_aa is table of dept_rty index by binary_integer;
  4       v_dept_aa dept_aa;
  5  begin
  6    v_dept_aa(10).deptNo:=10;
  7    v_dept_aa(20).deptNo:=20;
  8    for i in v_dept_aa.first..v_dept_aa.last loop
  9       if v_dept_aa.exists(i) then
 10             DBMS_OUTPUT.put_line(v_dept_aa(i).deptno);
 11       end if;
 12    end loop;
 13  end;

Related Topic