Was this helpful?
Dynamically Built Param Statements
EQUEL/C supports a special kind of dynamically built statement called a param statement. While the ability to supply names, expression values, and even entire qualifications in the form of host variables, as described in the QUEL Reference Guide, provides much dynamic flexibility, param statements considerably enhance this flexibility. Param statements determine at runtime, not only the names, but also the number and data types of target-list elements. This feature, for example, allows construction of a completely general program that can operate on any table or form that you specify at runtime.
A general restriction on param statements is that you cannot use param target lists in repeat queries.
In EQUEL/C, param versions are available for all statements in which:
Assignments are made between host variables and database columns
Assignments are made between host variables and form fields (or tablefield columns)
Not only retrieve, append, and replace, but also many forms-related statements such as getform, putform, initialize, loadtable, insertrow, and several others, have param versions.
Consider, again, the reason that these special versions of statements are needed. Non-param EQUEL statements, though relatively flexible in terms of substituting variables for expression constants, database and form object names, and entire where clauses, are nevertheless fixed at compile time in the number and data type of the objects to or from which assignment is made at runtime. Look at the following non-param retrieve statement, for example:
##  char   charvar1[100];
##  int    intvar1;
##  float  floatvar1;

##  char   table1[25];
##  char   col1[25], col2[25], col3[25];

** Assignments are made at runtime to all variables
** declared in the two lines immediately above,
** representing names of database objects. Then the
** following RETRIEVE statement gets data from the
** specified table and columns. 

##  retrieve (charvar1 = table1.col1,
##    intvar1 = table1.col2,
##    floatvar1 = table1.col3)
In this example, host variables represent all components of the target list—the table name and the names of all three columns. What cannot vary in this way of coding, however, is the fact that the retrieve statement gets values from exactly three columns, and that you must hard-code the data types of those three columns into the program. Param statements allow you to transcend those restrictions.
Last modified date: 06/10/2024