Database Guide
A host variable is a variable whose value can be substituted
into a query when the query is executed, as a way of passing a parameter to
the SQL statement.
Host variable names usually match a column name in your query, but are
prefixed by a colon (:). For example, a host variable for the
DEPT column might be :dept. The host variable can have
any name you like, but it can not contain double-byte characters.
To use a host variable in the sample application, edit the
StaffQuery query you created in the previous sections and add this
WHERE clause:
WHERE (STAFF.DEPT = :dept)
- Open the Multi-row Query Settings window and select the Edit
push button.
From the Clause menu in the SELECT Details window, select
WHERE.
- From the Left operand list in the WHERE Details window, select
STAFF.DEPT, and from the Operator list select
=.
- In the Right operand field, type dept, and then from
the Unary operator menu select Right operand
> Host variable :x.
- Select Apply in the WHERE Details window and in the SELECT
Details window.
Setting a host variable's data type
VisualAge provides a host variable editor that you can use to set or change
the data type for host variables.
- On page 2 of the Query Spec page in the Multi-row Query
Settings window, select the Host variables button.
The Host variables for window displays. This window lists all host
variables in the query.

- To edit a host variable's data type, select the host variable and
then select Edit.
The Edit host variable window displays.

- You can select a new data type from the drop-down list on this
window. The fields below the list change according to the data type
selected.
- Close these windows without changing the default data type for the
:dept host variable and then select OK in the
Multi-row Query Settings window.
- Display the connect pop-up menu for the multi-row query part. It
now includes dept, the host variable you used in the WHERE
clause.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]