6. Defining Frames with Visual Queries : Defining Specific Frame Types : Defining Append Frames
 
Share this page                  
Defining Append Frames
Append frames let users add records to tables. You can specify these features for the visual query of an Append frame:
Sequenced fields for the Master table
Default values for displayed columns
Assigned values for non-displayed columns
The figure in the following section shows a visual query window for an Append frame. The specifications in the figure correspond to the examples used in the discussion below.
Specify Sequenced Fields
To ensure that each record that users add on an Append frame has a unique value in the key field, you can specify that a column of the Master table appear as a sequenced field on the form. When a user calls the Append frame, Vision inserts a new integer value into the sequenced field.
Vision sets the value of the sequenced field to "1" for the first record to be added. Each time the user appends a record to the table, Vision increases the value of the sequenced field by one, thus ensuring that each record has a unique key.
For example, you can have an Append frame on which users add new orders. You can specify the order number column as a sequenced field on the form. Vision automatically generates a unique, sequential number for each new order.
You can specify one column on an Append frame as the sequenced field. This column:
Must be in the Master table
Must be a key column of the table
Can be either displayed or non-displayed
Must have a data type of integer(4) to hold the value that Vision generates
You cannot specify a sequenced field if you have displayed your Master table as a table field.
Vision increments the value of the sequenced field as follows:
If the sequenced field is displayed on the form and the user exits the frame without saving the record, Vision still increments the value of the field the next time the frame is called. Thus, it is possible to have "holes" in the sequence where records were not saved.
If the sequenced field is not displayed, Vision only increments the value when the user selects Save. In this case, there are no holes in the sequence.
To specify that a column appear as a sequenced field
1. Position the cursor on the name of the column in the Master table.
2. Tab to the Assignment/Default field.
3. Type the word sequenced.
Set Default Values for Displayed Fields
You can indicate a default value for a column displayed as a form field on an Append frame. This default value is displayed in the field or assigned as the value of a local variable (for a column marked as v in the visual query display) each time the form is cleared for new use.
For example, if you want the Date column to always contain the current date without the user having to enter it. You can specify 'today' (a built-in Ingres function) as the default value for the Date field.
The field for which you specify a default value:
Must be in the Master table
Must be displayed as a field on the form
Cannot already be assigned a value of "sequenced" (see Specify Sequenced Fields, in this topic)
If you have displayed your Master table as a table field, you cannot specify default values for columns of the table field.
To specify a default value for a Master table field
1. Position the cursor on the name of the column in the Master table.
2. Tab to the Assignment/Default field.
3. Enter a default value for the column.
The value must be consistent with the column's data type. The value can be in the form of an expression as described in Using Expressions in Frame Definitions.
Note:  Be aware that the user can type a new value over the default value that Vision places into a field. To prevent this from happening, edit the form to make the field display-only. When the user moves through the form, the cursor skips over this field and the user cannot enter any data into it.
Assign Values to Non-Displayed Columns
You can specify a value to insert into a non-displayed column (that is, a column marked as n in the visual query display) of an Append frame. For each new record that you append, Vision enters the value directly into the column without it appearing on the form.
In the example in the preceding figure, the quantity for each item ordered automatically is set at 100. Users cannot see--and, therefore, cannot change--this value.
The non-displayed column to which you assign a value:
Can be in the Master table or the Detail table
Cannot already be assigned a value of "sequenced" (see Specify Sequenced Fields, in this topic)
To specify an assigned value for a non-displayed column
1. Position the cursor on the name of the column.
2. Change the Display on Form indicator to n.
3. Tab to the Assignment/Default column in a Master table or the Assignment column in a Detail table.
4. Enter a value for the column.
The value must be consistent with the column's data type. The value can be in the form of an expression as described in Using Expressions in Frame Definitions.
How You Can Control Window Clearing
By default, Append frames are cleared each time a user selects Save. You can prevent the window from being cleared by setting the internal 4GL variable "IIclear" to "n" in escape code.
For example, put the following statement in a Form-Start escape:
IIclear = 'n';
For instructions on how to write escape code, see Using Vision Advanced Features.