Version 6.7.3

USING Clause

Function:

The USING clause is used to provide references to host variables for use in either a dynamic FETCH, OPEN or EXECUTE statement.

Invocation:

The USING clause is part of dynamic EXECUTE, FETCH or OPEN statements.

Syntax:

using_clause.jpg
 

host_variable_specification

A valid host variable specification and must have been defined in an application program. The host variable specification may reference a structure.

host_variable_identifier

A valid single host variable identifier and which 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 singularly.

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 use of a USING clause. Prior to use the referenced host variables must have been assigned appropriate values. 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 variables provided are intended to receive the results of the statement.

Host variables within the USING clause can be provided in two ways:

A host variable specification which references a host variable structure is equivalent to individual host variable specifications which reference all the elements of a structure singularly.

Limitations:

None.

ANSI Specifics:

The USING clause is not part of the Standard.

Adabas SQL Gateway Embedded SQL Specifics:

This is an Adabas SQL Gateway Embedded SQL extension.

 

Example:

The following example provides values for an 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;

Top of page