title: Call Oracle stored procedure from PHP
body: <p>I am trying to execute and get data from my procedure:</p>
  
  <p>Here is the way my procedure is defined:</p>
  
  <pre class="lang-sql prettyprint-override"><code>create or replace PROCEDURE SP_GET_MY_DATA(
           IN_POP VARCHAR2,
           IN_SEG VARCHAR2,
           IN_DUR VARCHAR2, 
           IN_VIEW INTEGER, 
           IN_PAGE INTEGER, 
           VIEW_DATA_CUR OUT SYS_REFCURSOR) AS ...
  </code></pre>
  
  <p>Here is my PHP code to execute and get data from procedure:</p>
  
  <pre><code>$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = JXYX.com)(PORT = 1521)))(CONNECT_DATA=(SID=DHSJKS)))";
  $conn = ocilogon("XXXXXX","XXXXXXXX",$db);          
  
  $sql = 'BEGIN SP_GET_MY_DATA(:POP, :SEG, :DUR, :VIEW, :PAGE, :OUTPUT_CUR); END;';            
  
  $stmt = oci_parse($conn,$sql);                     
  oci_bind_by_name($stmt,':POP',$pop);           
  oci_bind_by_name($stmt,':SEG',$seg);           
  oci_bind_by_name($stmt,':DUR',$dur);           
  oci_bind_by_name($stmt,':VIEW',$view);           
  oci_bind_by_name($stmt,':PAGE',$page);           
  $OUTPUT_CUR = oci_new_cursor($conn);
  oci_bind_by_name($stmt,":OUTPUT_CUR", $OUTPUT_CUR, -1, OCI_B_CURSOR);                   
  oci_execute($stmt, OCI_DEFAULT); 
  
  while ($data = oci_fetch_assoc($OUTPUT_CUR)) {
      print_r($data);
  }
  </code></pre>
  
  <p>But in doing so I am getting this error: </p>
  
  <blockquote>
    <p>oci_fetch_assoc(): ORA-24374: define not done before fetch or execute and fetch". </p>
  </blockquote>
  
  <p>I am not able to figure out what I'm missing. Can you help?</p>