Home » Database » MDB2_Driver_oci8 » Bug #3660
Permit oci8::execute bind input/output cursor/rowid/blob/bfile parameteres
Details
| Request #3660 | Permit oci8::execute bind input/output cursor/rowid/blob/bfile parameteres |
|---|---|
| Submitted | 2005-03-01 15:31 UTC |
| From | marcos at inf dot utfsm dot cl |
| Assigned | quipo |
| Status | Closed |
| Package | MDB2_Driver_oci8 |
| PHP Version | Irrelevant |
| OS | ANY |
| Roadmaps | (Not assigned) |
Comments
[2005-03-01 15:31 UTC] marcos at inf dot utfsm dot cl
Description:
------------
A call to a procedure/function with IN/OUT abstract Datatype (LOB/ROWID/BFILE) or ref cursor parameters fails because the binding needs an extra parameter (type) and the parameter needs to be allocated first using ocinewdescriptor/ocinewcursor.
Reproduce code:
---------------
$cursor = null;
$sth = $dbh->query("begin pkg.get_ref_cursor(?, ?); end;",
array(10, &$cursor ) ) ;
PL/SQL CODE:
CREATE OR REPLACE PACKAGE ELQUI.pkg AS
TYPE REF_CURSOR IS REF CURSOR;
PROCEDURE get_ref_cursor(n IN NUMBER, c out ref_cursor);
END;
/
CREATE OR REPLACE PACKAGE BODY ELQUI.PKG AS
PROCEDURE get_ref_cursor(n IN NUMBER, c out ref_cursor) IS
BEGIN
open c FOR
SELECT table_name from user_tables where rownum <= n;
END ;
END;
/
This patch adds the extra functionality needed to the execute method, so a call as shown will work as expected.
$cursor = null;
$sth = $dbh->query("begin pkg.get_ref_cursor(?, ?); end;",
array(10, array(&$cursor, OCI_B_CURSOR) ) ) ;
diff -ru DB.orig/oci8.php DB/oci8.php
--- DB.orig/oci8.php 2005-02-27 22:42:01.000000000 -0300
+++ DB/oci8.php 2005-03-01 11:49:44.029554305 -0300
@@ -641,10 +641,30 @@
$data[$key] = fread($fp, filesize($data[$key]));
fclose($fp);
}
- if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
- $tmp = $this->oci8RaiseError($stmt);
- return $tmp;
- }
+ /* Oracle especific parameter */
+ if ( is_array($pdata[$i]) ) {
+ if ($pdata[$i][0] == null) {
+ if ($pdata[$i][1] == OCI_B_CURSOR) {
+ $pdata[$i][0] = @OCINewCursor($this->connection);
+ } elseif ($pdata[$i][1] == OCI_B_ROWID) {
+ $pdata[$i][0] = @OCINewDescriptor($this->connection, OCI_D_ROWID);
+ } elseif ($pdata[$i][1] == OCI_B_CLOB || $pdata[$i][1] == OCI_B_BLOB ) {
+ $pdata[$i][0] = @OCINewDescriptor($this->connection, OCI_D_LOB);
+ } elseif ($pdata[$i][1] == OCI_B_BFILE || $pdata[$i][1] == OCI_B_CFILEE ) {
+ $pdata[$i][0] = @OCINewDescriptor($this->connection, OCI_D_FILE);
+ } else {
+ return $this->raiseError(DB_ERROR_MISMATCH);
+ }
+ }
+ if (!@OCIBindByName($stmt, ":bind" . $i, $pdata[$i][0], -1,
+ $pdata[$i][1])) {
+ return $this->oci8RaiseError($stmt);
+ }
+ } else /* normal parameter */
+ if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
+ $tmp = $this->oci8RaiseError($stmt);
+ return $tmp;
+ }
$i++;
}
if ($this->autocommit) {
Expected result:
----------------
Resource id #n in $cursor
Actual result:
--------------
DB Error: unknown error in $sth