DBAL-278: add support for lastInsertId method on OCI8 Driver #1457

doctrinebot opened this Issue May 16, 2012 · 1 comment

2 participants


Jira issue originally created by user franek:

The method lastInsertId() is not defined for OCI8 Driver in Doctrine\DBAL\Driver\OCI8\OCI8Connection.php :

public function lastInsertId($name = null)
    //TODO: throw exception or support sequences?

I propose this method to handle lastInsertId for sequence :

public function lastInsertId($name = null)
        // For sequence
        if (is_string($name)) {
            // We can check eventually check the presence of the sequence in the table
            // USER_SEQUENCES
            $sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL';
            // will throw an exception if this sequence does not exist
            $stmt = $this->query($sql);
            $result = $stmt->fetch(\PDO::FETCH_ASSOC);
            if ($result !== false && isset($result['CURRVAL'])) {
                return (int) $result['CURRVAL'];
    // OCI8 driver does not provide support of lastInsertId
    return null;



Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment