Host variable usage

Host variables can be used in the following circumstances:

  • SELECT, INSERT, UPDATE, and DELETE statements in any place where a number or string constant is allowed.

  • The INTO clause of SELECT and FETCH statements.

  • Host variables can also be used in place of a statement name, a cursor name, or an option name in statements specific to embedded SQL.

  • For CONNECT, DISCONNECT, and SET CONNECT statements, a host variable can be used in place of a server name, database name, connection name, user ID, password, or connection string.

  • For SET OPTION and GET OPTION, a host variable can be used in place of the option value.

Host variables cannot be used in the following circumstances:

  • Host variables cannot be used in place of a table name or a column name in any statement.

  • Host variables cannot be used in batches.

  • Host variables cannot be used within a subquery in a SET statement.

 SQLCODE and SQLSTATE host variables
 See also