DB2 10.5 for Linux, UNIX, and Windows

Compound SQL statement

A compound SQL statement is a sequence of individual SQL statements enclosed by BEGIN and END keywords.

There are three types of compound SQL statements:
  • Inlined: A compound SQL (inlined) statement is a compound SQL statement that is inlined at run time within another SQL statement. Compound SQL (inlined) statements have the property of being atomically executed; if the execution of any of the statements raises an error, the full statement is rolled back.
  • Embedded: Combines one or more other SQL statements (sub-statements) into an executable block.
  • Compiled: A compound SQL (compiled) statement can contain SQL control statements and SQL statements. Compound SQL (compiled) statements can be used to implement procedural logic through a sequence of SQL statements with a local scope for variables, conditions, cursors, and handlers.