| 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) |
[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
Comments
[2006年03月11日 09:49 UTC] User who submitted this comment has not confirmed identityIf you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE. Write a message to pear-dev@lists.php.net
to request the confirmation link. All bugs/comments/patches associated with this
email address will be deleted within 48 hours if the account request is not confirmed!
[2007年07月22日 16:25 UTC] User who submitted this comment has not confirmed identityIf you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE. Write a message to pear-dev@lists.php.net
to request the confirmation link. All bugs/comments/patches associated with this
email address will be deleted within 48 hours if the account request is not confirmed!