php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60703 support for reference cursors on pdo_oci
Submitted: 2012-01-10 19:55 UTC Modified: 2016-03-08 01:10 UTC
Votes:12
Avg. Score:4.8 ± 0.6
Reproduced:11 of 11 (100.0%)
Same Version:4 (36.4%)
Same OS:7 (63.6%)
From: marcos dot ramirez dot aranda at gmail dot com Assigned:
Status: Open Package: PDO OCI
PHP Version: 5.3.8 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marcos dot ramirez dot aranda at gmail dot com
New email:
PHP Version: OS:

 

 [2012-01-10 19:55 UTC] marcos dot ramirez dot aranda at gmail dot com
Description:
------------
PDO_OCI doesn't yet allow fetching ref cursors with oracle (or any other database). 

This patch adds support for fetching reference cursors on pdo_oci on both SELECT's as well CALL's to stored procedures (see the example below).


Test script:
---------------
$dbh = new PDO('oci:dbname=//localhost/XE', 'user', 'pass');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

$sql = "select cursor(select table_name, owner from all_tables where rownum <= 1) as cursor from dual";
$sth = $dbh->prepare($sql);
$sth->execute();

$row = $sth->fetch(PDO::FETCH_ASSOC);
var_dump($row);
if (is_a($row['CURSOR'],'PDOStatement')) {
    $sthc = $row['CURSOR'];
    while ($rr = $sthc->fetch(PDO::FETCH_ASSOC)) {
      var_dump($rr);
    }
 }
$sql = "begin OPEN :c FOR 'SELECT table_name FROM all_TABLES WHERE ROWNUM <= 1'; END;";

$sthc = '';
$sth = $dbh->prepare($sql);
$sth->bindParam(":c", $sthc, PDO::PARAM_STMT|PDO::PARAM_INPUT_OUTPUT);

$sth->execute();
if ($sthc && is_a($sthc,'PDOStatement'))
  while ($rr = $sthc->fetch(PDO::FETCH_ASSOC)) {
    var_dump($rr);
  }


Expected result:
----------------
array(1) {
  ["CURSOR"]=>
  object(PDOStatement)#3 (1) {
    ["queryString"]=>
    NULL
  }
}
array(2) {
  ["TABLE_NAME"]=>
  string(5) "ICOL$"
  ["OWNER"]=>
  string(3) "SYS"
}
array(1) {
  ["TABLE_NAME"]=>
  string(5) "ICOL$"
}


Actual result:
--------------
PHP Warning:  PDOStatement::fetch(): SQLSTATE[HY000]: General error: 932 OCIStmtFetch: ORA-00932: inconsistent datatypes: expected CHAR got DTYCWD


Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error: 932 OCIStmtFetch: ORA-00932: inconsistent datatypes: expected CHAR got DTYCWD
bool(false)
PHP Warning:  PDOStatement::execute(): SQLSTATE[HY000]: General error: 1008 OCIStmtExecute: ORA-01008: not all variables bound

Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: 1008 OCIStmtExecute: ORA-01008: not all variables bound


Patches

php-5.3.10-cursor-support-for-pdo_oci.patch (last revision 2012-03-20 10:19 UTC by psrustik at yandex dot ru)
php-5.3.8-cursor-support-for-pdo_oci.patch (last revision 2012-01-12 22:41 UTC by marcos dot ramirez dot aranda at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-20 05:22 UTC] gureedo at gmail dot com
attatched patch does not work with ZTS enabled configuration.
 [2012-03-20 10:21 UTC] psrustik at yandex dot ru
New php-5.3.10-cursor-support-for-pdo_oci.patch
also support with ZTS enabled configuration.
 [2016-03-08 01:10 UTC] sixd@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 13:01:29 2024 UTC