php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18368 Successful OCIExecute clears OCIError
Submitted: 2002-07-16 10:13 UTC Modified: 2002-10-17 08:38 UTC
From: eo at clickbase dot no Assigned: maxim (profile)
Status: Not a bug Package: OCI8 related
PHP Version: 4.2.0 OS: win2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: eo at clickbase dot no
New email:
PHP Version: OS:

 

 [2002-07-16 10:13 UTC] eo at clickbase dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-17 08:38 UTC] maxim@php.net
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 10:01:31 2024 UTC