CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Customised error messages for DB operations

Print topic Send  topic

Author Message
Harold
Posted: 06/12/2003, 7:49 AM

Hi,

Has anybody found a reasonable way to detect and intercept error messages produced by the Oracle OCI interface?

- I don't get an error message in the control (where I would expect it)
- I can't find any reasonable object that holds an error property.
- The error/warning messages are shouted out from somewhere beneath db_oci8.php

Probably it's so obvious I can't see it.

Anybody?

Regards, Harold
glerma
Posted: 06/12/2003, 12:41 PM

Ha! I've been wondering the same thing.

Your right about it being implemented in db_oci8.php

I'm currently working on a class extention for db_oci8 to get the OCI errors thrown to the controls. If you choose, you can leave an email and I will send you a copy if i succeed.

Or I may just paste it into Tips And Articles.

g.
Harold
Posted: 06/13/2003, 12:20 AM

Hi Glerma,

thanks for your reply.
I would of course appreciate your thoughts and code in this matter.
This MUST be of general interest, can't imagine any serious application that doesn't handle it's errors properly...

Your ideas are highly welcome on eitschgee at yahoo doot com.

I really wonder why Yes Software isn't picking this up. Their code has some error propagation, but it doesn't seem to do what they intended it to do...

Additionally, I have placed a support request, I'll keep you informed about their view.

Regards,
Harold

glerma
Posted: 06/13/2003, 11:32 AM

Harold.

I have had to reverse-engineer the db_oci8 class in order to get an understanding of how it works. It works well for what's needed for, however it is an external class that was not really integrated well into the Codecharge API.

db_oci8 does contain an errors array which captures the ORA error code, the error message and text provided.

I am still working on my class, but should be finished soon. I hope to create a class which integrates with Codecharge's API and that others may use easily.

Stay tuned.

g.
glerma
Posted: 06/13/2003, 12:18 PM

Harold. I did already find a way to catch the Oracle Errors, however it is not a global solution. In other words, you would have to do a page by page implementation of it.

If you are only interested in catching the Oracle errors for certain pages than this may help you out.


In order to catch an error from the Oracle, you may "hi-jack" the error codes from the current dataset Error .

The db_oci.php class file will create an associated array called Error.

DO NOT CONFUSE THIS WITH CODECHARGE STUDIO'S ERRORS ARRAY! THEY ARE TWO DIFFERENT ARRAYS.

Error should contain the following elements:
1. code: The Oracle Error Code
Example: 2292
2. message: The full message of the Oracle Error
Example: ORA-02292: integrity constraint (WEBUSER.SCONTSITEID_FK) violated - child record found
If using PHP >= 4.3
3. offset: Indicates the location of the error.
4. sqltext: The statement which caused the error.
Example: DELETE FROM SITE_ACCT WHERE SITE_ID = 30008

To explain how to trap the errors, let's use an example of trying to delete a record where there are is a Primary Key/Foreign Key relationship. If I were to try to delete a record from the Primary Key table, and there was a child record in the other, than an ORA-02292: integrity constraint error would occur.

So if I wanted to allow the user to see ANY errors, not just the ORA-02292, then I would do the following.

1. I would setup a Custom Code Event in the "After Execute Delete" Event.

2. I would then setup a simple test such as this:
if ($formname->ds->Error["code"] != 0) {
$formname->Errors->addError($formname->ds->Error['message']);
}

You can do other tests based on the Error['code'] too. That way you can throw the error to the screen for certain error codes.

This should help you
Regards,
George
wrjarvis
Posted: 07/18/2003, 10:19 AM

I am scratching my head on this one too. The ODBC messages that come out are not what I want my customer to see. In the case of a duplicate record the ODBC message is ugly but a message that just said "Duplicate Record Add Attempt" would be better. I would rather handle these errors in some sort of error handler for the app but I would settle for the page. Has there been any progress to resolve the error handling issues.

Regards,
Will

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.