title: How to pass String values through variable in VARRAY functions in PL/SQL
body: <p>How to pass String values through variable in VARRAY functions in PL/SQL.</p>
  
  <p>Coding:</p>
  
  <pre><code>create or replace
  PROCEDURE dynamic_query_build
  (
      vr_plan_sku_id     IN VARCHAR2
  )
  IS
    type plan_sku_id_array IS VARRAY(999) OF VARCHAR2(5000);
    plan_sku_id plan_sku_id_array;
    total integer;
    vrx_plan_sku_id VARCHAR2(3000);
  
  BEGIN
    vrx_plan_sku_id:= replace(vr_plan_sku_id,',',chr(39)||','||chr(39));
    vrx_plan_sku_id:=chr(39)||vrx_plan_sku_id||chr(39);
    --plan_sku_id := plan_sku_id_array('Apple','Apple','Orange','Banana');
    dbms_output.put_line(vrx_plan_sku_id);
    plan_sku_id := plan_sku_id_array(vrx_plan_sku_id);
  
    total := plan_sku_id.count;
    dbms_output.put_line('Array count: 'total);
  
  EXCEPTION
      WHEN OTHERS THEN
      raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
  END dynamic_query_build;
  </code></pre>
  
  <p><strong>Execution:</strong></p>
  
  <pre><code>set serveroutput on;
  declare
  vr_plan_sku_id varchar2(200) := 'Apple,Apple,Orange,Banana';
  BEGIN
     dynamic_query_build(vr_plan_sku_id);
  END;
  /
  </code></pre>
  
  <p><strong>My Output:</strong></p>
  
  <p>Array count: 1</p>
  
  <p><strong>Expected Output:</strong> </p>
  
  <p>Array count: 4</p>
  
  <p><strong>Explanation:</strong> 
  When i pass the string values like "plan_sku_id_array('Apple','Apple','Orange','Banana')"  then i am getting count values is 4.. But when i pass the same string through variables then it is considering whole value as single value in the varray.</p>