Using a host variable
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)
1. Open the Multi-row Query Settings window and select the Edit push button.
From the Clause menu in the SELECT Details window, select WHERE.
2. From the Left operand list in the WHERE Details window, select STAFF.DEPT, and from the Operator list select =.
3. In the Right operand field, type dept, and then from the Unary operator menu select Right operand > Host variable :x.
4. Select Apply in the WHERE Details window and in the SELECT Details window.
Setting a host variable's data type
VA Smalltalk provides a host variable editor that you can use to set or change the data type for host variables.
1. 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.
2. To edit a host variable's data type, select the host variable and then select Edit.
The Edit host variable window displays.
3. 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.
4. 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.
5. 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.
Last modified date: 06/01/2018