Some applications require that you use a single input transaction to update several tables in the same MODIFY procedure. If the tables are not defined in the same Master File, you can use the COMBINE facility to modify them as if they are one. |
In this section: How FOCUS Creates a COMBINE Structure How to: |
Note: In Maintain, you do not issue a COMBINE command to modify unrelated tables. Instead, you reference multiple tables in the MAINTAIN FILE command. For example:
MAINTAIN FILES EMPINFO AND COURSE
You can maintain up to 63 tables in a single MODIFY procedure that operates on a COMBINE structure. The COMBINE limit is 16 Master Files; however, each Master File can describe more than one table, for a total of 64 per procedure, minus one for the virtual root segment created by the COMBINE command.
The COMBINE facility links multiple tables and assigns a new name to them so FOCUS can treat the tables as a single structure. Tables in a COMBINE structure can have different SUFFIX attributes, but you cannot combine a FOCUS data source with anything except other FOCUS data sources.
Note: In Maintain, you can modify FOCUS data sources and RDBMS tables in the same procedure.
When you issue a COMBINE command, the COMBINE structure remains in effect for the duration of the FOCUS session or until you enter another COMBINE command. Only one COMBINE structure can exist at a time, so each subsequent COMBINE command replaces the existing structure.
Do not confuse COMBINE with the dynamic JOIN command. You use JOIN to report from multiple tables that share at least one common field or for LOOKUP functions. With the COMBINE facility, you can MODIFY multiple tables. COMBINE is part of the MODIFY command; only the MODIFY and CHECK FILE commands process COMBINE structures. The FIND function also works in conjunction with COMBINE (see The FIND Function).
Note that COMBINE considers the component structures to be unrelated. Although RDBMS referential integrity is enforced, FOCUS referential integrity does not apply to a COMBINE of single-table Master Files. Your procedure should check for and enforce referential integrity, if necessary.
COMBINE FILES file1 [PREFIX pref1|TAG tag1] [AND]
.
.
.
filen [PREFIX prefn|TAG tagn] AS asname
where:
Once you enter the COMBINE command, you can modify the combined structure.
The EMPINFO table contains employee number, last name, first name, hire date, department code, current job code, current salary, number of education hours, and bonus plan information. A second table, PAYINFO, is a historical record of the employee's pay history. It contains the employee number, date of increase, percent of increase, new salary, and job code. (File Descriptions and Tables, provides the Master and Access Files for these two tables.)
Each time a salary changes, both the EMPINFO and PAYINFO tables must reflect the change. Since both tables need to share data entered for employee number, salary and job code, this application is appropriate for the COMBINE facility. You can update both tables at the same time without having to define multi-table Master and Access Files.
The following figures represent the tables as separate entities.
EMPINFO table PAYINFO table |
To modify the tables simultaneously, issue the following sequence of commands at the FOCUS command level or in a FOCEXEC:
COMBINE FILES EMPINFO PAYINFO AS EMPSPAY
MODIFY FILE EMPSPAY
.
.
.
In the following picture, generated by the CHECK FILE command, FOCUS defines a new segment, identified as SYSTEM99, to be the root segment of the combined structure. SYSTEM99 acts as the traffic controller for this structure; it is a virtual (artificial) segment. It counts as one segment towards the total of 64 segments allowed in the COMBINE structure.
check file empspay pict |
The COMBINE facility makes it easy to modify many files with the same transaction. For additional information regarding the COMBINE facility of MODIFY, refer to your FOCUS documentation.
Prior to FOCUS Version 7.0, the data adapter used segment activation logic in MODIFY write operations that differed from that of standard FOCUS against FOCUS files.
In a multi-path file structure involving FOCUS files (including structures generated by the COMBINE command), INCLUDE or DELETE actions operate only on active segments in the subtree of the segment specified in the previous MATCH or NEXT command.
However, with external DBMS files, INCLUDE or DELETE actions would operate not only on active segments in the subtree of the segment specified in the MATCH or NEXT command, but also on any active segments to the right of that segment in the hierarchy (as displayed by the CHECK FILE PICTURE command).
Currently, the default data adapter behavior is consistent with the standard FOCUS behavior.
In Version 6.8, the SQL SET INCLUDE SUBTREE subcommand was needed on the line immediately following the MODIFY command to institute the standard FOCUS behavior for external DBMS files. The syntax is:
SQL SET INCLUDE SUBTREE
Note: If you need to invoke the old default behavior for upward compatibility reasons, use the following subcommand on the line immediately following the MODIFY command:
SQL SET INCLUDE LATERAL
Information Builders |