My Oracle Support Banner

RDBPROD: Add Transparent Error Logging to Application Programs (Doc ID 64693.1)

Last updated on APRIL 14, 2022

Applies to:

Oracle Rdb Server on OpenVMS - Version 5.1 and later
HP OpenVMS Alpha
HP OpenVMS Itanium


The error handling functions provided by SQL since version 5.1 of Oracle Rdb can supplement or add powerful error reporting functions to all applications.

It is important for database applications to accurately detect, report and log any errors returned by the database management system, so that support personnel can correctly analyze and correct the problems.

Unfortunately, many programs have inadequate error reporting.

Errors detected while executing a database operation are reported to application programs by SQL setting the variable SQLCODE in the SQLCA (SQL Communications Area) to a negative value.

In many cases, the SQLCODE is not systematically tested after each SQL verb: this then causes another SQL verb to fail further in the program, and this second error, if reported, often hides the original error.

Many programs only report the negative SQLCODE in case of problems. In almost all cases, the SQLCODE value does not provide sufficient information to identify the real error. That information is given in the error vector built by Oracle Rdb, which contains the complete list of error messages, together with context information (database name, constraint name, index name, etc ...).

Finally, programs usually write out the information onto the user terminal screen. Often, the end user is unable to record this information, or the information simply gets overwritten by other terminal activity.

Adding a good error tracking and logging mechanism to existing programs is not a trivial task: each SQL verb should be followed by a verification of the SQLCODE, and a branching into error logging code.

This article describes a simple method to easily add a complete error logging mechanism to any existing application.

It uses the mechanism offered beginning with version 5.1 of Oracle Rdb. SQL now provides a way for application developers to easily define error handling routines, called by SQL whenever an error is detected.


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.