title: Oracle Associative Array TYPE is not able to use in USING statement (If TYPE is declared within Package)
body: <p>If 'Associative Array variable' is <strong><em>declared globally</em></strong>, able to use that in <code>OPEN CURSOR USING</code> statement. <br></p>
  
  <p>If 'Associative Array variable' is <strong><em>declared within package</em></strong>, while use in <code>OPEN CURSOR USING</code> statement, getting compilation error.</p>
  
  <p>More details provided below</p>
  
  <p>I am storing some values in one Associative Array variable. Later iterating those values by taking them into Cursor like below,</p>
  
  <pre><code>strQuery := 'select DISTINCT column_value from table(CAST(:v_Assoc_Collection AS AssocArray_Date_t))';
  OPEN RefCur_Item FOR strQuery USING v_Assoc_Collection;
  </code></pre>
  
  <p>Here i used the Associative array variable 'v_Assoc_Collection' which is a type of 'AssocArray_Date_t'.</p>
  
  <p>If i declared that type 'AssocArray_Date_t', outside the package [ <code>CREATE OR REPLACE TYPE AssocArray_Date_t IS TABLE OF DATE;</code> ], then it is working properly.</p>
  
  <p>But, if I <strong><em>declare the type within the procedure</em></strong>, am getting compilation error. </p>
  
  <blockquote>
    <p>Error: PLS-00457: expressions have to
    be of SQL types. In : "OPEN RefCur_Item
    FOR strQuery USING
    v_Assoc_Collection;"</p>
    
    <p>Error: PL/SQL: Statement ignored. In :
    "OPEN RefCur_Item FOR strQuery USING
    v_Assoc_Collection;"</p>
  </blockquote>
  
  <p>For reference, code is provided below,</p>
  
  <pre><code>    -- Package Declaration
  CREATE OR REPLACE PACKAGE AssocTypePackage
  AS   
    Type CursorType IS REF CURSOR;      
  
    PROCEDURE AssocTypeProcedure(name IN VARCHAR2);
  END;
  
  
  -- Package Body
  CREATE OR REPLACE PACKAGE BODY AssocTypePackage
  AS
  PROCEDURE AssocTypeProcedure(
    name IN VARCHAR2
  )
  IS  
    strQuery             VARCHAR2(4000);
    v_Assoc_Collection   AssocArray_Date_t := AssocArray_Date_t();
  BEGIN
    FOR i IN 1..5
    LOOP      
      v_Assoc_Collection.EXTEND;
      v_Assoc_Collection(v_Assoc_Collection.COUNT) := &lt;&lt;someDate&gt;&gt;;               
    END LOOP;
  
    strQuery := 'select DISTINCT column_value from table(CAST(:v_Assoc_Collection AS AssocArray_Date_t))';
    OPEN RefCur_Item FOR strQuery USING v_Assoc_Collection;
    LOOP 
      -- ----
      -- some processing
      -- ----
    END LOOP; 
  END  AssocTypeProcedure; 
  END AssocTypePackage;
  </code></pre>