Host variable conventions

A host variable name must conform to C naming conventions.

You can use a host variable in an Embedded SQL statement wherever 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 returned. See Table 4-5 and Table 4-6 for details. You cannot 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. See Chapter 7, “Using Dynamic SQL.”

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.

strcpy (p_id, "12345");
 exec sql select pub_id into :p_id from publishers
 where pub_id like “:p_id”;

The following example is valid:

strcpy (p_id, “12345”);
 exec sql select pub_id into :p_id from publishers
 where pub_id like :p_id;