Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Collections
 

Decreasing the Size of an Array

You cannot delete an element inside the array. Even if you set it to NULL, it still exists. The only thing you can do is decrease the size of the array. SQL> SQL> declare   2      type month_va is varray(13) of VARCHAR2(20);   3      v_month_va month_va:=month_va();   4      v_count_nr number;   5  begin   6      v_month_va.extend(3);   7      v_month_va(1):='January';   8      v_month_va(2):='February';   9      v_month_va(3):='March';  10  11      v_month_va(2):=null;  12      if v_month_va.exists(2)  13      then  14         DBMS_OUTPUT.put_line('Object Exists');  15      end if;  16  17      v_month_va(3):=v_month_va(2);  18      v_month_va.trim(1);  19      DBMS_OUTPUT.put_line('Count:'||v_month_va.count);  20      DBMS_OUTPUT.put_line('Last:'||v_month_va.last);  21  end;  22  / Object Exists Count:2 Last:2 PL/SQL procedure successfully completed. SQL>