Was this helpful?
Inittable Statement--Initialize a Table Field
This statement initializes a table field, associating it with a data set.
Syntax
inittable formname tablename [tablemode]
    [(columnname = format {, columnname = format})]
Description
The inittable statement initializes a table field by linking it with a data set, specifying its mode, and defining any hidden columns.
A data set is the internal data structure that holds rows of values for the table field. An initialized table field can have many rows in its data set, even though not all can be displayed. For a full discussion of table fields and data sets, see Table Fields.
Formname specifies the name of the form in which the table field identified by tablename is displayed. You can express either name as a quoted or unquoted character string or as a program variable.
The tablemode sets the table field's display mode. It must be a quoted or unquoted character string or program variable that evaluates to one of the following values:
read
In this mode, the user can only browse the contents of the table field by scrolling through the values in the data set. This mode is normally used with table fields that merely display data or when all changes to the data are made by means of menu operations.
update
In this mode, the user can scroll through the values in the data set and change the data displayed. However, the user cannot add rows to the end of the data set. This mode is useful in applications that display a series of records for possible modifications by the user.
fill
This mode is similar to the update mode, except that it also allows the user to enter new rows at the end of the table field. Rows so entered are automatically recorded in the data set. Any column into which the user does not enter data is given a default value: 0 (zero) for numeric (float, float4, integer, smallint, integer1, and money) columns, and blanks for string (char, varchar, c, text, and date) columns. However, if the column is of a nullable data type, the default value is always null.
query
This mode has all the capabilities of the fill mode, but also allows the user to enter comparison operators (for example, <> or >=,) which can be retrieved into program variables. Query mode is useful for allowing a user to specify parameters for a database retrieval.
The mode of the table field is normally independent of the mode of its form. However, if the form is displayed in read mode, then the table field behaves as if it is in read mode also. The real mode of the table has not been lost, however.
The default mode is fill.
The optional column list is used to define hidden columns for the table field. Hidden columns are columns of data that are not displayed on the form and are therefore invisible and inaccessible to the user, but which can be accessed by the program in the same way the program accesses displayed columns. A columnname can be any valid Ingres name of up to 32 bytes and can be expressed as a quoted or unquoted character string literal or a program variable. The column's format defines its data type and length. The format can be any legal Ingres data type. See your query language reference guide for a complete list of legal data types.
The format can include the with null clause to specify that the hidden column is nullable or the not null clause to specify a non-nullable hidden column. Not null implies not null with default. By default, a hidden column is non-nullable.
For greater runtime flexibility, you can put the complete list of column names and formats in a single program string variable.
The inittable statement can appear at any point after the form that contains the table field has been declared. However, because a table field cannot have a data set associated with it until inittable is performed, most applications execute the inittable statement before displaying the form containing the table field.
If you issue the inittable statement twice for the same table field, the second execution eliminates the previous values in the data set. If the second execution specifies the same mode as the first, the second execution is functionally equivalent to the clear field statement.
Examples--inittable statement:
Example 1:
Initialize a table field in the read mode with no hidden columns.
exec frs inittable empform employee read;
Example 2:
Initialize a table field in the default mode and specify two hidden columns for it.
exec frs inittable empform employee
    (sal = float4, eno = integer);
Example 3:
If the program is in supervisor mode, initialize the employee table field in update mode. Otherwise, initialize it in read mode.
if (supervisor_mode) then
    mode = 'update';
else
    mode = 'read';
end if;
exec frs inittable empform employee :mode
    (eno = integer);
Example 4:
Initialize a table field with nullable hidden column.
exec frs inittable empform employee
    (spouse = varchar(40) with null);
Example 5:
Initialize a table field with a non-nullable hidden column.
exec frs inittable empform employee
    (salary = money not null);
Last modified date: 08/14/2024