whenever testing conditions

Each whenever statement can test for one of the following three conditions:

The precompiler generates warning messages if you do not write a whenever statement for each condition. If you write your own code to check for errors and warnings, suppress the precompiler warnings by writing a whenever...continue clause for each condition. This instructs the precompiler to ignore errors and warnings.

If you precompile with the verbose option, the precompiler generates a ct_debug() function call as part of each connect statement. This causes Client-Library to display informational, warning, and error messages to your screen as your application runs. The whenever statement does not disable these messages. For more information about precompiler options, see the Open Client and Open Server Programmer’s Supplement.

After an Embedded SQL statement executes, the values of SQLCODE and SQLWARN1 determine if one of the conditions exists. Table 8-3 shows the criteria whenever uses to detect the conditions:

Table 8-3: Criteria for the whenever statement

Condition

Criteria

sqlwarning

SQLCODE = 0 and SQLWARN1 = W

sqlerror

SQLCODE < 0

not found

SQLCODE = 100

To change the action of a whenever statement, write a new whenever statement for the same condition. whenever applies to all Embedded SQL statements that follow it, up to the next whenever statement for the same condition.

The whenever statement ignores the application program’s logic. For example, if you place whenever at the end of a loop, it does not affect the preceding statements in subsequent passes through the loop.