GOTO Keyword

Use the GOTO clause to transfer control to the statement that the label identifies when a specified exception occurs. The GOTO and GO TO keywords are ANSI-compliant syntax for this feature of embedded SQL languages like ESQL/C. The following Informix® ESQL/C code fragment shows a WHENEVER statement that transfers control to the label missing each time that the NOT FOUND condition occurs:
query_data()
   ...
   EXEC SQL WHENEVER NOT FOUND GO TO missing;
   ...
   EXEC SQL fetch lname into :lname;
   ...
   missing:
      printf("No Customers Found\n");

Within the scope of the WHENEVER GOTO statement, you must define the labeled statement in each routine that contains SQL statements. If your program contains more than one user-defined function, you might need to include the labeled statement and its code in each function.

If the preprocessor encounters an SQL statement within the scope of a WHENEVER ... GOTO statement, but within a routine that does not have the specified label, the preprocessor tries to insert the code associated with the labeled statement, but generates an error when it cannot find the label.

To correct this error, either put a labeled statement with the same label name in each UDR, or issue another WHENEVER statement to reset the error condition, or use the CALL clause to call a separate function.