SQL/MP Programming Manual for COBOL

Error and Status Reporting
HP NonStop SQL/MP Programming Manual for COBOL529758-003
9-17
Returning Information From the SQLCA
Terminal
Using HOMETERM is not always advisable because more error messages could be
generated than HOMETERM can handle. For example, an incorrect table name in a
DEFINE could make the table unavailable to a Pathway system. This error would
cause every server program to receive an SQL error each time it referred to that table.
Also, consider that other components of the system, such as TMF, might be using
HOMETERM. If HOMETERM is a printer, printing might be delayed, or if HOMETERM
is a terminal, messages can be lost when text exceeds the size of the screen buffer.
Another consideration is that access to HOMETERM might not be easy for an end user
of the application. Suppose that the end user is notified that something failed, but the
error text is sent to HOMETERM. The end user might find it difficult to determine the
exact reason for the failure to correct it. If many errors are routed to HOMETERM, the
database administrator might find it difficult to match the error to the user. Processing
so many errors can also be time consuming.
Errors File
An option in SQLCA_DISPLAY2_ allows errors and warnings to be routed to a file. You
might consider this alternative, but it has the disadvantage that you must write a
program to extract the errors and warnings from the file.
You could write a separate process to monitor the file and print the messages as they
arrive. The process could search the file for specific errors. If the prefix and suffix of the
messages contain unique data, such as the terminal ID and a timestamp, the process
could use this data to locate and report on specific errors.
SQL Errors Table
Instead of sending errors to a file, send the errors to a nonaudited SQL table. Using an
SQL table makes it easy to retrieve the error information from the table with SQLCI.
Users or database administrators can formulate queries to answer their questions and
to monitor the systems. The report writer facilities of SQLCI help you produce complete
reports.
You use a nonaudited table so you can keep a log of messages generated by backed
out transactions. If you use an audited table, messages are lost when they are
associated with transactions backed out by TMF. Another advantage is that inserts to a
nonaudited table do not incur TMF overhead.
Your SQL error routine could include a call to SQLCA_TOBUFFER2_ to send the error
messages to a storage buffer and a call to SQLCAFSCODE to obtain any file system
errors associated with the SQL error. Then, you could code your program to insert a
row into the table.
You can create the error table as a key-sequenced table with a timestamp as the
primary key and indexes on other useful information. Although you could create a
relative table that allows rows to be appended at the end, or an entry-sequenced table,
a key-sequenced table with alternate keys offers the best searching capability.