#18368 [Opn->Bgs]: Successful OCIExecute clears OCIError
| From: | maxim@php.net | Date: | Thu, 17 Oct 2002 13:38:45 +0000 |
| Subject: | #18368 [Opn->Bgs]: Successful OCIExecute clears OCIError | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-22661@lists.php.net to get a copy of this message | ||
ID: 18368
Updated by: maxim@php.net
Reported By: eo@clickbase.no
-Status: Open
+Status: Bogus
Bug Type: OCI8 related
Operating System: win2000
PHP Version: 4.2.0
-Assigned To:
+Assigned To: maxim
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is the way OCIError() should work. OCIError() returns the errors
from the last Statement called, it does not buffer any previos errors
that happened within the script and shows its last one.
Perhaps you're right about the documentation. It should be saying:
"return the error for the last Statement or Connection executed"
instead of
"return the last error occured"
because this way it feels like if there was an error it'll get printed
out regardless when it happened but as long as nothing failed after
it.
I will move this bug into the documentation issues.
Thanks Eirik,
Maxim Maletsky
maxim@php.net
Previous Comments:
------------------------------------------------------------------------
[2002-07-16 10:13:25] eo@clickbase.no
I'm not really sure this is considered a bug, but in my view it's
certainly an unexpected behaviour.
Here's the case:
In the end of a transaction of several insert/update statements, I'd
like to check if all the statements executed without errors before
deciding whether to commit or roll back:
...
$stmt = ociparse($conn,$qry1);
@ociexecute($stmt, OCI_DEFAULT);
$stmt = ociparse($conn,$qry2);
@ociexecute($stmt, OCI_DEFAULT);
$stmt = ociparse($conn,$qry3);
@ociexecute($stmt, OCI_DEFAULT);
$stmt = ociparse($conn,$qry4);
@ociexecute($stmt, OCI_DEFAULT);
/* etc... */
if (!OCIError($stmt))
OCICommit($conn);
else
OCIRollback($conn);
...
The problem is that if the execution of qry3 crashes and qry4 is OK,
OCIError returns false and the transaction is committed.
Since handling transactions must be the most useful area for an
error-array like this, I'd expect the behaviour described in the
documentation of OCIError: "Return the last error of stmt|conn|global".
Now it returns the error of the last statement run - and if the last
statement was successful, it returns false (regardless of what the last
error was).
Regards
Eirik Olsen
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18368&edit=1