Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-596

OCI8 - ORA-06502 executing a procedure with out parameters (potentially very large out parameters)

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.4
    • Component/s: Drivers
    • Security Level: All
    • Labels:
    • Environment:
      Symfony 2.3.4, PHP 5.4.6-1ubuntu1.2, Apache, Linux

      Description

      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

      Initial function
          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);               
              }
          }
      
      Modified function
          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

        Activity

        Show
        Steve Müller added a comment - Fixed in commit: https://github.com/doctrine/dbal/commit/8d7e9c9951fec89677b426f7935214a806dc9839

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Francois G.
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: