Was this helpful?
Syntax of Param Statements
These statements are called param statements because of the param function in place of its target list. The param function has the following syntax:
param (target_stringvar_address_array)
Thus, for example, a param retrieve statement might look like this:
##  retrieve (param (target, varadr))
##  where qstr
The target_string is a formatted target list string that can be either a Fortran character variable or a Fortran character constant. Normally it is a variable, since the purpose of this feature is to allow statements to be built at runtime. The var_address_array is an array of locations to which values are assigned at runtime. The elements in this array then hold the addresses of variables of appropriate types to receive or supply data for the table columns or form fields with which the param statement interacts.
The target_string looks like a regular target list expression, except where a Fortran variable intended to receive or supply data in an assignment would normally appear. In place of these names, the target_string contains symbolic type indicators representing the variables. For each of these type indicators appearing in the target list, there must be an address recorded in the corresponding element of the var_address_array, beginning with var_address_array(1).
Linux: If your system does not include the loc built-in function to obtain addresses of integer and real variables, you can use the IInum( ) function provided with EQUEL.
Windows: The "loc" intrinsic function (or the "%loc" built-in function) is used to access the address of variables.
To obtain the address of a character variable, you can use the IIstr( ) function (Linux) or IIdesc() function (Windows) provided with EQUEL. Examples of these functions appear at the end of this section.
At runtime, EQUEL processes the statement by associating the variable addresses with the type indicators embedded in the target_string. Addresses must have been previously placed in the cells of the array in a sequence corresponding to the sequence of type indicators in the target_string, such that the statement can find a list of the correct number of Fortran variables of the correct type.
The variable-type indicators can be any of the following:
i2            two-byte integer (integer*2)
i4            four-byte integer (integer*4)
f4            four-byte floating-point number (real*4)
f8            eight-byte floating-point number
               (real*8 or  double precision)
c[N]       character string
In the list above, the length specifier N is optional. The default length is the size of the character variable.
In this context, the format indicator must always agree with the Fortran variable that supplies or receives the data. This format does not necessarily need to be the same as that of the column where the data is stored in the database. Store data to be retrieved from, or inserted into, table columns of type date in character arrays with a minimum length of 25 in your program. Retrieve items of type money into program variables of type real*4 or real*8.
When you reference ordinary character-string data in a param target list, use the c type indicator with or without specifying the number of characters to be assigned. The optional length specification has the following effect, depending on the kind of statement in which the target list appears:
In an input statement, such as append or putform, the length specification, N, attached to a c type indicator, limits to N the number of bytes actually assigned from the Fortran character variable to the database or form object. The default is to assign as many bytes from the Fortran variable as can be accommodated in the database or form object after trimming trailing blanks.
In an output statement, such as retrieve or getform, the length specification limits to N the number of bytes of actual data assigned from the database or form object to the Fortran character variable. In the absence of the length specifier, EQUEL writes into the variable as much of the data as the variable can hold. The Fortran character variable is always padded with blanks, if the length of the data is shorter than that of the variable.
The following examples show a param append statement:
Linux:
  program param

##  DECLARE

C Declare variables to be used for supplying data to 
C the database

##   character*27     chvar
##   integer*4        intvar
##   real*8           rvar

C Declare variables for the PARAM target list, the array C
of variable addresses, and the database table to be
C used.

##   character*100    tlist
##   integer*4        varadr(3)
##   character*25     tblnam

C Now assign values to variables in order to set up 
C the PARAM statements. In a real application, this
C would be done during the process of interacting with
C the user, as well as by obtaining information from 
C the system catalogs, or from the FRS, about the
C number and data type of table columns. In this
C example, the assignments are hard-coded.

     tblnam = 'employee'
C The following target list is for use with the APPEND
C statement. Note that the type indicators appear on the
C right-hand side of the assignments. Column names
C appear on the left-hand side.

     tlist = 'empname=%c, empnum=%i4, salary=%f8'

C The next three statements assign, to an array of
C integers, the addresses of variables which will 
C supply data for the APPEND statement. Note the use of
C the EQUEL functions 'IInum and IIstr' to access the
C address of the variables.

     varadr(1) = IIstr (chvar) 
     varadr(2) = IInum(intvar) 
     varadr(3) = IInum(rvar)

C Next, values are assigned to the data variables
C themselves. Again, in an actual application this 
C would likely be done by interacting with the user.

     chvar       = 'Jane Swygart'
     intar       = 332
     rvar        = 37500.00

##   ingres personnel
##   append to tblnam (PARAM (tlist, varadr))
##   exit
     end  
Windows:
program param_example

##   declare

C Declare variables to be used for supplying data to 
C the database

##   character*27       ch_var
##   integer*4          int_var 
##   real*8             real_var

C Declare variables for the PARAM target list, the 
C array of variable addresses, and the database table 
C to be used.

##   character*100      targlist 
##   integer*4          varaddr(4) 
##   character*25       tablename
C Data types
    integer*4 DATE, MONEY, CHAR, VARCHAR, INT, FLOAT, C, TEXT
    parameter (DATE =    3,
     1        MONEY    =    5,
     2        CHAR    =    20,
     3        VARCHAR =    21,
     4        INT    =    30,
     5        FLOAT    =    31,
     6        C    =    32,
     7        TEXT    =    37 )
C Now assign values to variables in order to set up 
C the PARAM statements. In a real application, this
C would be done during the process of interacting with
C the user, as well as by obtaining information from
C the system catalogs, or from the FRS, about the 
C number and data type of table columns. In this
C example, the assignments are hard-coded.

    tablename = 'employee'

C The following target list is for use with the APPEND
C statement. Note that the type indicators appear on 
C the right-hand side of the assignments. Column names
C appear on the left-hand side.

    targlist = 'empname=%c, empnum=%i4, salary=%f8'

C The next three statements assign, to an array of
C integers, the addresses of variables that will supply
C data for the APPEND statement. 
C Note the use of the EQUEL function 'IIdesc' to access
C the address of the character variable.
C The type and the length of the Fortran character variable
C needs to be supplied
                  varaddr(1) = IIdesc (ch_var, CHAR, LEN(ch_var)) 
                  varaddr(2) = %loc(int_var) 
                  varaddr(3) = %loc(real_var)
C Next, values are assigned to the data variables
C themselves. Again, in an actual application this 
C would likely be done by interacting with the user.

                  ch_var = 'Jane Swygart' 
                  int_var = 332 
                  real_var = 37500.00

##  ingres personnel 
##  append to tablename (PARAM (targlist, varaddr)) 
##  exit 
    end  
Last modified date: 08/14/2024