Using program variables
As a 4GL query is handled via the bshell, you can directly relate program variables to it. Linking program variables is required for both the SELECT clause and the WHERE clause.
In the <select list> of the SELECT clause, program variables are used to indicate the elements in which the query results must be stored. You can do this by explicitly specifying a program variable. The general syntax is:
<select part>:<program variable>
Or you can directly use a program variable (a table or field name) from the calling program in the <select list>. For example:
In the first example, the program places the result in the <program variable>. In the second example, the name in the query and the name of the program variable are identical.
You can also use program variables in the WHERE clause. When evaluating the query, the program loads the values of the program variables into the query and includes them in the evaluation. This link can be realized by incorporating a program variable in the query, preceded by a colon [:]. For example:
WHERE ppmod123.field1 = :myval1
A table field can be a program variable as well as a query variable. Note that the following query:
where tccom010.cuno = tccom010.cuno
has a different result from:
where tccom010.cuno = :tccom010.cuno
The latter selects one record; the former selects all records from the table tccom010, as tccom010.cuno by definition equals tccom010.cuno for each row.