5. Embedded SQL for Ada : The SQL Communications Area : Error Handling Using the SQLCA : The Whenever Goto Action in Embedded SQL Blocks
 
Share this page                  
The Whenever Goto Action in Embedded SQL Blocks
An Embedded SQL block-structured statement is a statement delimited by the begin and end clauses. For example, the select loop and the unloadtable loops are both block-structured statements. You can terminate these statements only by the methods specified for the particular statement in the SQL Reference Guide. For example, the preprocessor terminates the select loop either when all the rows in the database result table have been processed or by an endselect statement, and the preprocessor terminates the unloadtable loop either when all the rows in the forms table field have been 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 an Ada return, exit, goto, or raise statement that causes control to leave or enter an SQL block.) The target label of the whenever goto statement should be a label in the block. If however, 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, nor to explicit hard-coded error handling. For an example of hard-coded error handling, see The Table Editor Table Field Application (see page The Table Editor Table Field Application) in this chapter.