SQL control statements for external SQL procedures

SQL control statements for external SQL procedures can be used only with SQL procedures that are created with the FENCED or EXTERNAL clause. SQL control statements provide the capability to control the logic flow, declare and set variables, and handle warnings and exceptions. Some SQL control statements include other nested SQL statements.

SQL-control-statement:
Read syntax diagram
>>-+-assignment-statement------+-------------------------------><
   +-CALL statement------------+   
   +-CASE statement------------+   
   +-compound-statement--------+   
   +-GET DIAGNOSTICS statement-+   
   +-GOTO statement------------+   
   +-IF statement--------------+   
   +-ITERATE statement---------+   
   +-LEAVE statement-----------+   
   +-LOOP statement------------+   
   +-REPEAT statement----------+   
   +-RESIGNAL statement--------+   
   +-RETURN statement----------+   
   +-SIGNAL statement----------+   
   '-WHILE statement-----------'   

Control statements are supported in SQL procedures. External SQL procedures are created by specifying either FENCED or EXTERNAL, LANGUAGE SQL, and an SQL routine body on the CREATE PROCEDURE (SQL - external) statement. The SQL routine body must be a single SQL statement which may be an SQL control statement.

The remainder of this section contains a description of the control statements that are supported for external SQL procedures, and includes syntax diagrams, semantic descriptions, usage notes, and examples of the use of the statements that constitute the SQL routine body. In addition, you can find information about referencing SQL parameters and variables in References to SQL parameters and SQL variables.

The two common elements that are used in describing specific SQL control statements are: