Whenever Goto Action In Embedded SQL Blocks
An embedded SQL block-structured statement is delimited by the words begin and end. For example, the select loop and unloadtable loops are all block-structured statements. You can only terminate these statements by the methods specified for the particular statement in the SQL Reference Guide. For example, the select loop is terminated either when all the rows in the database result table are processed or by an endselect statement. The unloadtable loop is terminated either when all the rows in the forms table field are processed or by an endloop statement.
Therefore, if you use a whenever statement with the goto action in an SQL block, you must avoid going to a label outside the block. Such a goto causes the block to be terminated without issuing the runtime calls necessary to clean up the information that controls the loop. (For the same reason, you must not issue a C return or goto statement that causes control to leave or enter the middle of an SQL block.) The target label of the whenever goto statement should be a label in the block. However, if it is a label for a block of code that cleanly exits the program, the above precaution need not be taken.
The above information does not apply to error handling for database statements issued outside an SQL block, or to explicit hard-coded error handling. See the example of hard-coded error handling in (see page
The Table Editor Table Field Application in this chapter.