php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50906 ORA-03131: an invalid buffer was provided for the next piece(Same as Bug#39820)
Submitted: 2010-02-02 10:11 UTC Modified: 2014-01-01 12:49 UTC
Votes:6
Avg. Score:4.0 ± 1.5
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: symphony dot group at yahoo dot com Assigned:
Status: Open Package: PDO OCI
PHP Version: 5.2.12 OS: Irrelevant
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-02-02 10:11 UTC] symphony dot group at yahoo dot com
Description:
------------
When binding out variables, you have to specify the data type and length manually with PDO_OCI.

If not you receive an oracle error:

ORA-03131: an invalid buffer was provided for the next piece

This bug exists in both PHP 5.2.12 and 5.3.1

Reproduce code:
---------------
the following simple code easily re-produces the bug:

try {
        $dbConn = new PDO('oci:dbname=.....);
        $dbConn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        $sql = $dbConn->prepare("
                        BEGIN
                                SELECT  username
                                INTO    :chkId
                                FROM    USERS
                                WHERE   username = 'fred';
                        END;
                        ");
        $sql->bindParam('chkId', $chkId);
        $sql->execute();
        var_dump($chkId);
} catch (Exception $e) {
        var_dump($e);
}

obviously I've censored our connection info.

as the other user mentioned in bug #39820 if I alter the bindParam to:

$sql->bindParam('chkId', $chkId, PDO::PARAM_STR, 10);

it works. however even missing off the variable length causes a error

Expected result:
----------------
string ('fred');

Actual result:
--------------
object(PDOException)#3 (8) {
  ["message":protected]=>
  string(173) "SQLSTATE[HY000]: General error: 3131 OCIStmtExecute: ORA-03131: an invalid buffer was provided for the next piece
 (....../php-5.3.1/ext/pdo_oci/oci_statement.c:146)"
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  string(5) "HY000"
  ["file":protected]=>
  string(20) "/root/pdoOciTest.php"
  ["line":protected]=>
  int(14)
  ["trace":"Exception":private]=>
  array(1) {
    [0]=>
    array(6) {
      ["file"]=>
      string(20) "/root/pdoOciTest.php"
      ["line"]=>
      int(14)
      ["function"]=>
      string(7) "execute"
      ["class"]=>
      string(12) "PDOStatement"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(0) {
      }
    }
  }
  ["previous":"Exception":private]=>
  NULL
  ["errorInfo"]=>
  array(3) {
    [0]=>
    string(5) "HY000"
    [1]=>
    int(3131)
    [2]=>
    string(136) "OCIStmtExecute: ORA-03131: an invalid buffer was provided for the next piece
 (...../php-5.3.1/ext/pdo_oci/oci_statement.c:146)"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-11 01:44 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: sixd
 [2012-10-26 05:57 UTC] sixd@php.net
-Assigned To: sixd +Assigned To:
 [2014-01-01 12:49 UTC] felipe@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Wed Jun 28 02:01:37 2017 UTC