Welcome Guest, Not a member yet? Register   Sign In
Oracle Nextval issue
#13

[eluser]Unknown[/eluser]
I was having the same problem -- calling something like:
Code:
$q = $this->db->query('SELECT somesequence.NEXTVAL FROM dual');
$result = $q->row();          // Increments three times
$result = $q->result();       // Increments three times
$result = $q->row_array();    // Increments two times
$result = $q->result_array(); // Increments two times

Looking deeper, I found that the function num_rows() in CI_DB_oci8_result (oci8_result.php) is calling ociexecute. This seems to be what's causing the extra DB queries that leads to the sequence getting incremented more than it should.

To remedy this, I altered the function to read as:
Code:
function num_rows()
{
    if ( $this->num_rows )      return $this->num_rows;
    if ( $this->result_array )  return count($this->result_array);
        
    return count($this->result_array());
    ...
}

In addition to that, I had to overwrite CI_DB_result's result_object() and row_object() functions for the oci8 driver.

This probably won't cover all the use cases, but it seems to be working for my application.


Messages In This Thread
Oracle Nextval issue - by El Forum - 04-02-2009, 03:42 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 04:22 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 04:31 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 04:42 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 05:44 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 05:56 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 06:27 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 06:37 PM
Oracle Nextval issue - by El Forum - 04-02-2009, 10:27 PM
Oracle Nextval issue - by El Forum - 04-03-2009, 04:41 AM
Oracle Nextval issue - by El Forum - 04-03-2009, 08:32 AM
Oracle Nextval issue - by El Forum - 10-15-2009, 09:52 AM
Oracle Nextval issue - by El Forum - 10-20-2009, 04:02 PM
Oracle Nextval issue - by El Forum - 03-07-2010, 05:20 PM
Oracle Nextval issue - by El Forum - 05-13-2013, 04:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB