Was this helpful?
Using the Sort Clause in Param Retrieves
Unlike the non-param version of the retrieve statement, the param version has no application-supplied names for result columns. The non-param retrieve uses the same names as for the host variables used to receive the data, but in a param retrieve these names are not present in the statement. Only the type indicators are seen by the EQUEL runtime system when the param retrieve is executed.
In order to meet the need for result column names in the statement, Ingres generates internal names. If you want to include a sort clause in a param retrieve, you must use the internally generated result column names as arguments to the sort clause. These names are "ret_var1", "ret_var2", and so forth, named sequentially for all the result columns represented by type indicators in the target list. (Ignore null indicators in determining this sequence.) For example, assume a target list as in the previous section:
tlist = "%c:%i2=e.empname,%f8:%i2=e.salary";
If you want to retrieve and sort by the result column representing salary, you must supply the internal name "ret_var2" to the sort clause:
##   retrieve (param(tlist,varaddr))
##   sort by ret_var2:d
This sorts by the second result column, in descending order.
Last modified date: 06/10/2024