title: Retrieving the return value of an insert...value 'return into' statement using codeigniter (oracle oci 8)
body: <p>Firstly I apologise if this is a duplicate!</p>
  
  <p>Say I have a PL/SQL anonymous block stored in a PHP variable <code>$sql</code>, ready to be executed and is laid out thus:</p>
  
  <pre><code>BEGIN
    INSERT INTO TABLE_NAME(PARAM1, PARAM2, PARAM3)
    VALUES(?,?,?)
    RETURNING TABLE_NAME.PARAM1 INTO ?;
  END; 
  </code></pre>
  
  <p>Using the Codeigniter framework, I want to be able to perform this statement:</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query($sql, array('1', 'Hello', 'World', $id));
  </code></pre>
  
  <p>...and then be able to access the returned variable of '1', which should be stored in the <code>$id</code> variable.</p>
  
  <p>I know that the syntax I have provided wouldn't necessarily work, I've just used it to demonstrate what I'm trying to achieve.</p>
  
  <p>I don't believe the OCI8 driver is equipped to handle returning variables from a statement in this way. I can't seem to find a way to manually bind a variable (in this case <code>$id</code>) to the RETURN...INTO clause of the PL/SQL statement. Normally I could do:</p>
  
  <p><code>oci_bind_by_name($stid, ':id', $id) //replace '?' with ':id' on the RETURN...INTO section of the anonymous block</code></p>
  
  <p>...However, I have tried to implement this using the <code>$this-&gt;db-&gt;call_function()</code> but that did not work either. I have been digging around the code to try and find a way to extend the driver to do this but I fear I may be complicating things or I am going about it the wrong way.</p>
  
  <p><strong>EDITED QUESTION 8/4/14:</strong></p>
  
  <p><strong>I know how to select a column variable I want to return. What I'm unsure about is how I can bind that returned variable to a PHP variable inside the codeigniter framework.</strong></p>
  
  <p>Super thanks in advance! :)</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <ol>
  <li>I've edited the question to be clearer (emboldened above.)</li>
  <li>I'm using the returned value as a foreign key in subsequent statements. </li>
  <li>I'm auto incrementing the 'PARAM1' column using a trigger and a sequence.</li>
  </ol>