php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58860 oci_error return false when NO_DATA_FOUND is raised
Submitted: 2009-09-18 07:29 UTC Modified: 2009-10-09 13:14 UTC
From: michael dot virnstein at brodos dot de Assigned: sixd (profile)
Status: Closed Package: oci8 (PECL)
PHP Version: 5.2.10 OS: debian
Private report: No CVE-ID: None
 [2009-09-18 07:29 UTC] michael dot virnstein at brodos dot de
Description:
------------
When the database error NO_DATA_FOUND is raised, oci_error returns false instead of the error in oci8 1.3.5.

Reproduce code:
---------------
<?php 

$conn = oci_connect('user', 'pass', 'db');

$stmt = oci_parse($conn, 'begin raise NO_DATA_FOUND; end;');

oci_execute($stmt, OCI_DEFAULT);

var_dump(oci_error($stmt));

?>

Expected result:
----------------
oci_error returning the oracle error

Actual result:
--------------
oci_error returns false (no error)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-18 13:40 UTC] christopher dot jones at oracle dot com
NO_DATA_FOUND raises a warning, not an error.  See oci_
 [2009-09-18 13:41 UTC] christopher dot jones at oracle dot com
NO_DATA_FOUND is generally not an error: null data sets are still valid sets.  In PHP it will raise a warning.  See php_oci_error() in oci8.c.  

If you want to indicate an application failure when there is no data, catch the NO_DATA_FOUND exception in PL/SQL and raise your own exception:

declare 
  my_failure exception; 
begin 
  raise NO_DATA_FOUND; 
  exception 
    when NO_DATA_FOUND then 
      raise my_failure; 
end
 [2009-09-18 13:42 UTC] christopher dot jones at oracle dot com
Thank you for taking the time to write to us, but this is not
a bug.

This is expected behaviour.
 [2009-09-18 18:36 UTC] michael dot virnstein at brodos dot de
NO_DATA_FOUND resulted in an error in oci8 1.2.5, but it doesn't in 1.3.5.
 [2009-09-18 18:42 UTC] michael dot virnstein at brodos dot de
This change breaks lot's of code, which i have to rewrite now. I'm also not with you on the point, that NO_DATA_FOUND is no error. NO_DATA_FOUND is a perfectly valid exception in PL/SQL and I don't see a point in raising other exceptions instead.
 [2009-09-21 18:26 UTC] christopher dot jones at oracle dot com
Compatibility is a good trump statement.  Let me evaluate the scope of the issue and determine which behavior we should move forward with.

If the code is to change, a quick fix seems to be to add "errcode = 1403;" to the OCI_NO_DATA case in php_oci_error().
 [2009-10-01 02:01 UTC] christopher dot jones at oracle dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

---------

Fixed in PHP 5.3.2 and 6.0.  The fix will also appear in any PECL OCI8 that occurs after the current OCI8 1.3.5 release. A request for the fix to be merged to PHP 5.3.1 has been submitted.

http://svn.php.net/viewvc?view=revision&revision=289039
 [2009-10-09 13:14 UTC] christopher dot jones at oracle dot com
The fix has been merged to PHP 5.3.1.
PECL OCI8 1.4.0 Alpha also contains the fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 14:01:28 2024 UTC