Declaring and using host variables

About this task

In HCL OneDB™ ESQL/C applications, the SQL statements can refer to the contents of host variables. A host variable is an ESQL/C program variable that you use to transfer information between the HCL OneDB ESQL/C program and the database.

You can use host variables in HCL OneDB ESQL/C expressions in the same way that you use literal values except that they cannot be used:
  • In prepared statements
  • In stored procedures
  • In check constraints
  • In views
  • In triggers
  • As part of a string concatenation operation

To use a host variable in an SQL statement:

Procedure

  1. Declare the host variable in the C program.
  2. Assign a value to the host variable.
  3. Specify the host variable in an embedded SQL statement.