Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

#27672 [Asn]: oci_error() doesn't return a error if oci_execute() errored.
ID:               27672
Updated by:       tony2001@php.net
Reported By:      powerblade at mail dot dk
Status:           Assigned
Bug Type:         Documentation problem
Operating System: Windows XP
PHP Version:      5CVS-2004-03-24 (dev)
Assigned To:      tony2001
New Comment:

You can use old names as well.
They are still available as aliases of new functions.


Previous Comments:
------------------------------------------------------------------------

[2004-03-24 11:09:45] powerblade at mail dot dk

Just checked it out.
It seems your right.
It's a documentation problem only. But still enough to confuse some
people. :)
You already  me by changing all the function names a few ws
ago.

------------------------------------------------------------------------

[2004-03-24 11:01:13] tony2001@php.net

you need to pass $stmt to oci_error(); in this case.
so, your code will look like this:
<?

/* ... */
$query = 'XYZZYX'; /* Invalid SQL string */

$stmt = oci_parse($this->connection, $query);

$return = @oci_execute($stmt);

if($return === FALSE)
{
$aError = oci_error($stmt); //$stmt here
throw new DatabaseException("[".$aError['code']."] Can't execute
query. ".$aError['message']);
}

?>

Requalifying as documentation problem and assigning to myself..

------------------------------------------------------------------------

[2004-03-24 10:48:26] powerblade at mail dot dk

Not only the documentation.
See my #2.

-----

2) Where is the oracle error message in the exception? I need that
info
for debugging.

-----

If you look in the exception you get:

-----------------------
Fatal error: Uncaught exception 'DatabaseException' with message '[]
Can't execute query. ' in /www/index.php:31 Stack trace: #0 {main}
thrown in /www/index.php on line 31
--------------------------------

The oracle error message and code is not included in the exception.
Even though in the code it threw the exception with the following
statement:
throw new DatabaseException("[".$aError['code']."] Can't execute
query. ".$aError['message']);
The only way to grab the oracle error is to set up a custom error
handler. You can't use oci_error() to retrieve it.

------------------------------------------------------------------------

[2004-03-24 10:40:49] tony2001@php.net

Aha, now I see...
It seems to me, that our manual lies about validation.

That's what OCI docs say about oci_parse (OciStmtPrepare() indeed):
--
An application requests a SQL or PL/SQL statement to be prepared for
execution using the OCIStmtPrepare() call and passing it a previously
allocated statement handle. This is a completely local call, requiring
no round trip to the server.
--

oci_parse will return false only if there is some problems with oracle
connection.
The only way to validate query is to execute it.

So, I need to change the documentation.
Right?

------------------------------------------------------------------------

[2004-03-24 10:24:09] powerblade at mail dot dk

Check your output.

1) The error was first detected by oci_execute(). oci_parse() didn't
detect the errornous SQL string.
2) Where is the oracle error message in the exception? I need that info
for debugging.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27672

--
Edit this bug report at http://bugs.php.net/?id=27672&edit=1

Report this thread to moderator Post Follow-up to this message
Old Post
tony2001@php.net
03-27-04 04:18 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Documentation archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:43 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.