title: in normal oracle function : ORA-06531: Reference to uninitialized collection
body: <p>my function is executing perfectly but while declaring it , showing errors. The code is:</p>
  
  <pre><code>set serveroutput on
  
  create or replace type myarray is varray(10000) of number;
  
  create or replace function T_Bill (cus_id in integer) return number as
      t_cost number:=0;
      n integer;   
      bk myarray;
      pr myarray;
      q myarray;   
  begin
      select count(book_id) into n from issue where cust_id=cus_id;
      select book_id,quantity BULK COLLECT into bk,q from issue where cust_id=cus_id;
      for i in 1..n
      loop
          select price into pr(i) from book where ISBN=bk(i);
          DBMS_OUTPUT.PUT_LINE(bk(i)||' '||q(i));
          t_cost:=pr(i);
      end loop;
  
      return t_cost;
  end;
  /
  </code></pre>
  
  <p>And Im declaring it like this:</p>
  
  <pre><code>declare 
   x integer:=1;
   begin
   DBMS_OUTPUT.PUT_LINE(T_Bill(x));
   end;
   /
  </code></pre>
  
  <p>And the errors are :</p>
  
  <pre><code>ORA-06531: Reference to uninitialized collection
  ORA-06512: at "R1507090.T_BILL", line 12
  ORA-06512: at line 4
  </code></pre>
  
  <p>Thanks in advance.</p>