ASA Programming Guide
Embedded SQL Programming
Using host variables
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 commands specific to embedded SQL.
For CONNECT, DISCONNECT, and SET CONNECT, a host variable can be used in place of a user ID, password, connection name, connection string, or database environment name.
For SET OPTION and GET OPTION, a host variable can be used in place of a user ID, option name, or option value.
Host variables cannot be used in place of a table name or a column name in any statement.
The following is valid embedded SQL:
INCLUDE SQLCA; long SQLCODE; sub1() { char SQLSTATE[6]; exec SQL CREATE TABLE ... }
The following is not valid embedded SQL:
INCLUDE SQLCA; sub1() { char SQLSTATE[6]; exec SQL CREATE TABLE... } sub2() { exec SQL DROP TABLE... // No SQLSTATE in scope of this statement }
The case of SQLSTATE and SQLCODE is important and the ISO/ANSI standard requires that their definitions be exactly as follows:
long SQLCODE; char SQLSTATE[6];