Skip to content

Loading…

DBAL-596: OCI8 - ORA-06502 executing a procedure with out parameters (potentially very large out parameters) #1809

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user fgerthoffert:

Currently converting a business application from a custom-built framework to Symfony, with Doctrine and OCI8 driver.

I noticed the following error when executing a procedure with out parameters.

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

We are returning potentially very large values.

This can be fixed very easily, by doing a small change on bindParam() :
File: doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php

    public function bindParam($column, &$variable, $type = null,$length = null)
    {
        $column = isset($this->*paramMap[$column]) ? $this->*paramMap[$column] : $column;

        if ($type == \PDO::PARAM_LOB) {
            $lob = oci*new_descriptor($this->_dbh, OCI_D*LOB);
            $lob->writeTemporary($variable, OCI*TEMP*BLOB);

            return oci*bind_by_name($this->_sth, $column, $lob, -1, OCI_B*BLOB);
        } else {
            return oci*bind_by_name($this->*sth, $column, $variable);               
        }
    }
    public function bindParam($column, &$variable, $type = null,$length = null)
    {
        $column = isset($this->*paramMap[$column]) ? $this->*paramMap[$column] : $column;

        if ($type == \PDO::PARAM_LOB) {
            $lob = oci*new_descriptor($this->_dbh, OCI_D*LOB);
            $lob->writeTemporary($variable, OCI*TEMP*BLOB);

            return oci*bind_by_name($this->_sth, $column, $lob, -1, OCI_B*BLOB);
        } else {
            if ($length != null) {
               return oci*bind_by_name($this->*sth, $column, $variable, $length);
            } else {
               return oci*bind_by_name($this->*sth, $column, $variable);               
            }
        }
    }

This modification requires very small changes, there is already a $length = null parameter, it's just a matter of using it.

Note that I'm not returning a LOB, so the first part of the function does not apply to my situation.

Thanks

@doctrinebot

Comment created by @deeky666:

Fixed in commit:
8d7e9c9

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.4 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.