How SQL statements are invoked

SQL statements are invoked in different ways depending on whether the statement is an executable or nonexecutable statement or the select-statement.

The SQL statements are classified as executable or nonexecutable. The description of each statement includes a heading on invocation that indicates whether or not the statement is executable.

Executable statements can be invoked in the following ways:

  • Embedded in an application program
  • Dynamically prepared and executed
  • Dynamically prepared and executed using DB2® ODBC function calls
  • Issued interactively

Depending on the statement, you can use some or all of these methods. The section on invocation in the description of each statement tells you which methods can be used.

A nonexecutable statement can only be embedded in an application program.

The select-statement is an additional SQL statement construct. (See select-statement.) It is used in a different way from other statements.

A select-statement can be invoked in the following ways:

  • Included in DECLARE CURSOR and implicitly executed by OPEN
  • Dynamically prepared, referred to in DECLARE CURSOR, and implicitly executed by OPEN
  • Dynamically executed (no PREPARE required) using a DB2 ODBC function call
  • Issued interactively

The first two methods are called, respectively, the static and the dynamic invocation of select-statement.