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:8
Avg. Score:3.9 ± 1.5
Reproduced:5 of 6 (83.3%)
Same Version:1 (20.0%)
Same OS:2 (40.0%)
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: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: symphony dot group at yahoo dot com
New email:
PHP Version: OS:

 

 [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
 [2022-11-23 05:35 UTC] sheyda dot babi5161 at gmail dot com
I faced similar kind of issue last time, I am still searching for some proper solution. (https://www.hca-rewards.net/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC