SQL-procedure-statement (external)

An SQL control statement may allow multiple SQL statements to be specified within the SQL control statement. These statements are defined as SQL procedure statements.

Syntax

Read syntax diagramSkip visual syntax diagramSQL-label:SQL-control-statementSQL-statement

Description

SQL-label
Specifies a label for the statement. SQL-label must not be a delimited identifier that includes lowercase letters or special characters. The label must be unique within the procedure.
SQL-control-statement
Specifies an SQL statement that provides the capability to control logic flow, declare and set variables, and handle warnings and exceptions, as defined in this section. Control statements are supported in SQL procedures.
SQL-statement
Specifies an SQL statement. These statements are described in SQL statements in Db2 for z/OS.

Notes

Comments: Comments can be included within the body of an SQL procedure. In addition to the double-dash form of comments (--), a comment can begin with /* and end with */. The following rules apply to this form of comment:

  • The beginning characters /* must be adjacent and on the same line.
  • The ending characters */ must be adjacent and on the same line.
  • Comments can be started wherever a space is valid.
  • Comments can be continued to the next line.

Handling errors and warnings: Conditions can be detected within an SQL procedure by using the following methods:

  • Test the special SQL variables SQLSTATE and SQLCODE.
  • Issue a GET DIAGNOSTICS statement to request the condition information. See GET DIAGNOSTICS statement.
  • Define condition handlers to detect and process conditions. See compound-statement for information about defining condition handlers.