Home » Database » DB » Bug #1338
Permit oci8:execute() bind output
Details
| Request #1338 | Permit oci8:execute() bind output |
|---|---|
| Submitted | 2004-05-04 19:35 UTC |
| From | dave at mausner dot us |
| Assigned | danielc |
| Status | Duplicate |
| Package | DB |
| PHP Version | 4.3.5 |
| OS | win2000 |
| Roadmaps | (Not assigned) |
Comments
[2004-05-04 19:35 UTC] dave at mausner dot us
Description:
------------
because execute is defined as "execute($stmt,$data)" one cannot bind to output variables -- only input variables. if one prepares a package function call which outputs results via its parameters, the binding occurs but the output data values are not transmitted back to the caller of execute.
...
therefore, i request that you consider a way to make an output binding succeed via PEAR. i would consider any of these a fair alternative:
(a) a special "prepare" binding code character which indicates an output value which is copied back thru another array;
(b) changing the prototype to "execute($stmt,&$data)" so that the binding occurs in the callers address space;
(c) anything else which is reasonable.
...
here is a workaround:
consider the case of:
$code = "begin dbms_output.get_line(:M,:S); end;";
this code returns a message into :M and a status into :S.
the explicit binding codes are necessary because "?" is bound to the address space of "execute" and is thus inaccessible.
$sth = $dbh->prepare($code);
it is necessary to mix metaphors by calling the OCI8 API:
ociBindByName($sth,":M",$msg,255);
ociBindByName($sth,":S",$okk,NULL);
which allows me to bind to my own address space:
while (true) {
$res =& $dbh->execute($sth);
if ($okk) break;
echo("$msg\n");
}
the above WORKS but is contrary to the spirit of PEAR.
Reproduce code:
---------------
$sth = $dbh->prepare(begin dbms_output.enable(1000); dbms_output.put_line('Hello.'); end;");
$dbh->execute($sth);
$sth = $dbh->prepare("begin dbms_output.get_line(?,?); end;");
$msg = "NONE RETURNED";
$okk = 99;
while (true) {
$dbh->execute($sth,array($msg,$okk);
if ($okk) break;
echo("$msg\n");
}
echo($okk);
Expected result:
----------------
Hello.
1
Actual result:
--------------
NONE RETURNED
99