title: Subscript out of limit error while using arrays in Pl/SQL
body: <p>The following program accesses arrays in PL/SQL, however when I execute the procedure, it gives me a subscript outside limit error. Why does this happen? I don't see anything wrong with this procedure  </p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE ANALYSIS
  IS
  CURSOR EMPLOYEES IS
   SELECT * FROM EMPLOYEE;
  CURSOR BILLS IS
   SELECT * FROM BILL;
  WORKER EMPLOYEE%ROWTYPE;
  CASH BILL%ROWTYPE;
  TYPE SALARY IS VARRAY(4) OF NUMBER(5);
  SALARIES SALARY;
  
  BEGIN
   SALARIES:=SALARY(1,1,1,1);
   SALARIES.EXTEND(4);
   OPEN EMPLOYEES;
   OPEN BILLS;
   LOOP
    FETCH EMPLOYEES INTO WORKER;
    EXIT WHEN EMPLOYEES%NOTFOUND;
    IF WORKER.BRANCHID=1 THEN 
     SALARIES(1):=SALARIES(1)+WORKER.SALARY;
    ELSIF WORKER.BRANCHID=2 THEN 
     SALARIES(2):=SALARIES(2)+WORKER.SALARY;
    ELSIF WORKER.BRANCHID=3 THEN 
     SALARIES(3):=SALARIES(3)+WORKER.SALARY;
    ELSIF WORKER.BRANCHID=4 THEN 
     SALARIES(4):=SALARIES(4)+WORKER.SALARY;
    END IF;
   END LOOP;
  END;
  </code></pre>