VISION

From Support Wiki

Jump to: navigation, search

Runtime Behavior

What happens with add/update/delete operations on forms where a master/detail relationship is defined?

The following describes the master-detail behaviour in Unify VISION for each of the basic selected set commands. A general overview of the master-detail feature is given in the "Unify VISION: Concepts" manual.

CLEAR-TO-FIND

If the current form is a master form, the detail form is cleared and disabled.

If the current form is a detail form, the CLEAR-TO-FIND operation has no effect on the master form. Any clear to find expressions defined on key fields in the detail form are ignored. Only records with key fields which match the master form may be selected.

FIND

If a FIND operation is performed on a master form, both a CLEAR-TO-FIND and FIND operation are automatically performed on all detail forms. The key values from the master form are used as search criteria on the detail form Additional search criteria may be specified on the detail form, however, the key values must match regardless of any other criteria. All of the normal code sections associated with the CLEAR-TO-FIND and FIND operations are executed on both master and detail forms. If no matching records are found on the detail form then a CLEAR-TO-ADD operation is performed on the detail form. Whether or not records are found, the detail form will be in add/update mode when the FIND operation on the master completes.

A FIND operation on a detail form has no effect on the corresponding master form. As stated above, the key values from the master form are always used as search criteria on the detail form.

CLEAR-TO-ADD

If the current form is a master form and the detail form's selected set contains at least one record, then a CLEAR-TO-FIND operation is performed on the detail. Otherwise, no corresponding operation is performed on the detail other than resetting the key fields.

If the current form is a detail form, the normal CLEAR-TO-ADD processing is executed but any key fields will be initialized to current key values from the master form.

ADD

If an ADD operation is performed on a master form, both a CLEAR-TO-FIND and a FIND are performed on all detail forms. If the find operation does not return any records then a CLEAR-TO-ADD operation is performed on the detail form. However, if the detail form was already in ADD/UPDATE mode when the ADD operation was performed on the master, and the current record on the detail form has been modified since the last ADD/UPDATE, FIND or CLEAR-TO-ADD operation, the current record on the detail form is saved before the CLEAR-TO-FIND and FIND are performed.

An ADD operation on a detail form has no effect on the corresponding master form unless the master form's current record has not been saved. In that case an ADD/UPDATE operation would be performed on the master prior to adding the detail record.

UPDATE

If an UPDATE operation which changes a key field is performed on a master form, then the changed value is propagated to all detail forms. That is, an update is performed on each detail form to change all the key values in the detail form to match those in the master. When an UPDATE operation occurs on a master form, ADD/UPDATE operations are also performed on any detail forms where the current record has been modified since the last ADD/UPDATE, FIND or CLEAR-TO-ADD operation.

An UPDATE operation on a detail form has no effect on the corresponding master form unless the master form's current record has not been saved. In that case an ADD/UPDATE operation would be performed on the master prior to updating the detail record. Users are not allowed to update keys to values which do not match the corresponding fields in the master form. Key fields cannot be modified on the screen of the detail form and will result in an error if they are changed via the 4GL.

DELETE

There is no special interaction between a DELETE operation and the master-detail feature. However, users should be aware that most RDBMS will not allow a master record to be deleted if corresponding detail records exist. Some RDBMS allow a cascading delete which will delete records in both the master and detail target tables when a delete operation is performed on the master. After a DELETE operation on a master form the records in all detail forms are changed because a new record is made current. See the CHANGE RECORD section below.

CHANGE RECORD

Anytime the current record is changed on a master form, both a CLEAR-TO-FIND and a FIND operation are automatically performed on all detail forms. The new key values from the master form are used as search criteria on the detail form. See the FIND section above.

A change record operation on a detail form has no effect on the corresponding master form.

Code sections executed during propagated ADD/UPDATE operations

Prior to Vision 5.0BC, if an ADD/UPDATE on a master form triggered an ADD/UPDATE on a detail or vice-versa, the BEFORE/AFTER ADD/UPDATE code sections would not fire on any form other than the form that initiated the ADD/UPDATE. This has been changed with the addition of a new Boolean External Preference MASTER_DETAIL_ADD_UPDATE. This preference controls whether the BEFORE/AFTER ADD/UPDATE code sections fire for Master-Detail forms. MASTER_DETAIL_ADD_UPDATE defaults to FALSE, in which case there will be no change in the VISION behavior. If MASTER_DETAIL_ADD_UPDATE is set to TRUE then the BEFORE/AFTER ADD/UPDATE code sections will fire when doing an automatic add or update due to either a master form or a detail form update.

Runtime 4GL statement limitations:

When the manager is in the state of performing an automatic add or update due to either a master form or a detail form, the following 4GL statements will raise an error:

CANCEL FORM CHOOSE FORM USING CREATE FORM DISMISS FORM MAKE CURRENT NEXT ACTION

These statements will not work in this case because they terminate the current method (code section).

Edited by Support 11:53, 21 November 2006 (PST)