USING Clause
Function:
The USING clause is used to provide references to host variables for use in a dynamic FETCH, OPEN, or EXECUTE statement.
Invocation
The USING clause is part of dynamic EXECUTE, FETCH or OPEN statements.
Syntax
host_variable_specification | A valid host variable specification that must be defined in an application program. The host variable specification can reference a structure. |
host_variable_identifier | A valid single host variable identifier that must be the address of an SQL descriptor area (SQLDA). |
Description:
The USING clause defines a set of host variables for use either as value sources in a dynamic OPEN or EXECUTE statement, or as target receptors in a dynamic FETCH statement.
A host variable specification, which references a host variable structure, is equivalent to individual host variable specifications which reference all the elements of the structure one by one.
For a dynamic OPEN or EXECUTE statement, if the associated prepared statement contained host variable markers, i.e., `?', then these markers must be satisfied by the use of a USING clause. The referenced host variables must be assigned appropriate values prior to use. Each referenced host variable provides a value for its corresponding host variable marker. The user must make sure that the host variables are supplied with the correct values and formats in the correct order.
For a dynamic FETCH statement, the host provided variables are intended to receive the results of the statement.
Host variables within the USING clause can be provided in two ways:
Explicitly specify a list of host variables. The number, type, and order of the required host variables must be known at compilation time of the host program.
Provide an SQL descriptor area. This facility enables the adoption of a more dynamic approach. The DESCRIBE statement provides the necessary information in the SQLDA for each host variable marker or derived column. The user must then provide a pointer in each field description which references an appropriate host variable. The number, type, and order of the host variables can be completely unknown at compilation time of the host program. An SQL descriptor area is identified by means of a host variable which contains the address of the SQLDA.
Limitations:
None.
ANSI Specifics:
The USING clause is not part of the Standard.
CONNX Embedded SQL Specifics:
This is an Adabas SQL Gateway Embedded SQL extension.
Here is an example on how to provide values for an EXECUTE statement which requires the input of three values, for example, 'SELECT * FROM contract WHERE price IN ( ?, ?, ? ). The USING clause provides these values.
USING :hv1, :hv2, :hv3;