Host variable conventions

A host variable name must conform to COBOL naming conventions.

You can use a host variable in an Embedded SQL statement only if a Transact-SQL literal can be used in a Transact-SQL statement at the same location.

A host variable must conform to the valid precompiler datatypes. The datatype of a host variable must be compatible with the datatype of the database column values that are returned. See Table 4-3 and Table 4-4 for details.

Do not use host language reserved words and Embedded SQL keywords as variable names.

A host variable cannot represent Embedded SQL keywords or database objects, except as specified in dynamic SQL. For more information on using host variables to represent keywords for database objects, see Chapter 4, “Using Variables.”

When a host variable represents a character string in a SQL statement, do not place it within quotes.

The following example is invalid because the precompiler inserts quotes around values when necessary. You should not type the quotes.

exec sql select pub_id from publishers
     where pub_id like ":PUB-ID"
end-exec

The following example is valid:

exec sql select pub_id from publishers
     where pub_id like :PUB-ID
end-exec