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.

Deprecated function: Start of changeExternal SQL procedures are deprecated and not as fully supported as native SQL procedures. For best results, create native SQL procedures instead. For more information, see Creating native SQL procedures and Migrating an external SQL procedure to a native SQL procedure.End of change
SQL-control-statement:
Read syntax diagramSkip visual syntax diagramassignment-statementCALL statementCASE statementcompound-statementGET DIAGNOSTICS statementGOTO statementIF statementITERATE statementLEAVE statementLOOP statementREPEAT statementRESIGNAL statementRETURN statementSIGNAL statementWHILE 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 statement (SQL - external procedure) (deprecated) 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 in external SQL procedures.

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