As shown at 10 in Figure 3-1, you use the SQLEXPLAIN command
to obtain a message from the ALLBASE/SQL message catalog that
describes the condition related to the SQLCA value:
EXEC SQL SQLEXPLAIN :SQLMessage
|
ALLBASE/SQL puts a message from the ALLBASE/SQL message catalog
into the host variable named SQLMessage, and the program
displays the message.
Sometimes more than one message may be needed to completely
describe how an SQL command executed. To obtain multiple
messages, the program in Figure 3-1 executes SQLEXPLAIN until
SQLCode contains a value of 0. ALLBASE/SQL sets SQLCode to 0
when no more messages are available.
If you use the value of SQLCode to control the flow of the
program, you may need to save the SQLCode value into a variable
before the SQLEXPLAIN command is executed. The value of SQLCode
represents the result of only the previously executed SQL
command.
You can use SQLEXPLAIN in conjunction with either implicit or
explicit status checking. In the program in Figure 3-1, the
subprogram unit SQLStatusCheck is executed from the line labeled
500, which is used in conjunction with the first WHENEVER
SQLERROR command in the program.
The default message catalog is SQLCTxxx.PUB.SYS. For native
language users, the catalog is SQLCT000.PUB.SYS, where
NATIVE-3000 is the current language. If this catalog is not
available, ALLBASE/SQL issues a warning and uses the default
catalog instead.