16. Table Fields : How Table Fields Can Be Used in an Application : inittable Statement—Initialize a Table Field
 
Share this page                  
inittable Statement—Initialize a Table Field
A table field becomes associated with a data set when it is initialized. The initialization, which must occur after the form has been declared to the FRS, sets up the structure of the underlying data set; it does not actually put any data into the data set. The inittable statement initializes a table field..
This statement has the following syntax:
inittable formname tablename [tablemode]
[(columnname = format {, columnname = format})];
formname
Specifies the name of the form in which the table field tablename is displayed
tablemode
Specifies one of the display modes described in Table Field Display Modes (read, update, query or fill). The default mode is fill.
You can optionally include hidden columns in the table field by enumerating them in the inittable statement. Hidden columns are identical to other table field columns, except that they are not displayed in the table field and therefore are invisible to the runtime user. The program can access values in hidden columns, just as it can access values in displayed columns. A typical use for a hidden column is as a repository for the unique identifying information (such as the employee number for an employee) of each row that is loaded into the data set from a database table. Once the user has modified the rows in the table field, the program can use the hidden column values within a search condition to update rows of the database table.
Unlike other columns in the table field, which are defined in Visual Forms Editor, hidden columns are defined when the table field is initialized.
columnname
Specifies the name by which the hidden column in the column list for inittable can be accessed
format
Indicates its storage format. The format must be a legal Ingres SQL data type from the following list.
Data Type
Meaning
char(1)-char(n)
Fixed length character string (all ASCII characters) of the specified length; n represents the lesser of the maximum configured row size and 32,000.
c1-cn
Fixed length character string (printing characters only) of the specified length; n represents the lesser of the maximum configured row size and 32,000.
varchar(1)-varchar(n)
Variable length character string (all ASCII characters) of the specified length; n represents the lesser of the maximum configured row size and 32,000.
text(1)-text(n)
Variable length character string (all ASCII characters except nulls); n represents the lesser of the maximum configured row size and 32,000.
integer1
1-byte integer
smallint
2-byte integer
integer
4-byte integer
float4
4-byte floating point
float
8-byte floating point
decimal
Exact numeric data type defined in terms of precision (total number of digits) and scale (number of digits to the right of the decimal point)
date
12-byte date value (displayed as a 25-character string)
money
8-byte money value (displayed as a 20-character string)
See the SQL Reference Guide for details about these data types.
The optional clauses with null and not null can follow the data type specification. By default, hidden columns are set to not null.
For example, the following embedded SQL statement sets up two hidden fields:
exec frs inittable empform employee update
     (sal = float4, eno = integer);
This defines a data set for the employee table field in the empform form. The table field is in update mode and contains two hidden columns, sal and eno. The table field also has the displayed columns defined for it in Visual Forms Editor; these are ename and age, with the titles Name and Age, as shown in the preceding figure.