AcuODBC User's Guide
6.2.2 Defaults Used in XFD Files
There are several elements of COBOL file descriptors that require special handling when data dictionaries are built. These include multiple record definitions, REDEFINES, FILLER, and OCCURS. This section describes how ACUCOBOL(TM)-GT handles each of these situations.
As described earlier, in many instances you can override the default behavior described below by placing directives in the FDs of your COBOL code. Directives are described in section 6.3, "Using Directives." For example, the WHEN directive allows you to use multiple definitions for a single set of data by specifying when each definition should be used.
Like most data sources, Vision does not support the notion of multiple definitions for the same column. As the following paragraphs explain, whenever a COBOL program gives more than one definition for the same data, the compiler makes a choice about which definition to use in the dictionary. Then it disregards the rest.
KEY IS phrase
Fields named in KEY IS phrases of SELECT statements are included as column names in the "virtual" database. Other fields that occupy the same areas as the key fields (by either explicit or implicit redefinition) are not included by name, but are mapped to the key field column names by the data dictionary.
Remember, if the field named in the KEY IS phrase is a group item, it will not be included in the XFD unless a USE GROUP directive is used (see section 6.2.1, "How the Data Dictionary Is Formed").
Fields contained in a redefining item occupy the same positions as the fields being redefined. The compiler needs to select only one of the field definitions to use. The default rule that it follows is to use the fields in the item being redefined as column names; fields that appear subordinate to a REDEFINES clause are mapped to column names in the "virtual" database using the data dictionary.
Multiple record definitions
This same rule extends to multiple record definitions. In COBOL, multiple record definitions are redefinitions of the entire record area. This leads to the same complication that is encountered with REDEFINES: multiple definitions for the same data. So the compiler needs to select one definition to use.
Because the multiple record types can be different sizes, the compiler must use the largest one, so that it can cover all of the fields adequately. Thus, the compiler's rule is to use the fields in the largest record defined for the file. If more than one record is of the largest size, the compiler uses the first one.
Note that group items are, by default, never included in a data dictionary for the same reason that REDEFINES are excluded: they result in multiple names for the same data items, and they are shown in the XFD file as a comment. You can, however, choose to combine grouped fields into one data item by specifying the USE GROUP directive, described in section 6.3.10.
FILLER data items
In a COBOL FD, FILLER data items are place holders. FILLER items are not uniquely named and thus cannot be uniquely referenced. For this reason, they are not placed into the Acucorp data dictionary. The dictionary maintains the correct mapping of the other fields, and no COBOL record positional information is lost.
If your ODBC application refers to a FILLER data item, you may need to include it. In such a case, you could include it under a USE GROUP directive or give it a name of its own with the NAME directive, described in section 6.3.7.
An OCCURS clause always requires special handling, because the ACUCOBOL-GT compiler must assign a unique name to each database column. The compiler accomplishes this by appending sequential index numbers to the item named in the OCCURS.
For example, if the following were part of a file's description:03 employee-table occurs 20 times. 05 employee-number pic 9(3)
these column names would be created in the "virtual" database table, that is, the "table" of Vision data created when AcuODBC performs its translation:employee_number_1 employee_number_2 . . . employee_number_10 employee_number_11 . . . employee_number_20
Note that the hyphens in the COBOL code are translated to underscores in database field names, and the index number is preceded by an underscore.
Identical field names
In COBOL you distinguish fields with identical names by qualification. For example, there are two fields named MONTH in the following code, but they can be qualified by their group items. Thus, you would reference MONTH OF LAST_VISIT and MONTH OF LAST_PAYMENT in your program:10 last_visit. 15 month pic 99. 15 day pic 99. 15 year pic 99. 10 last_payment. 15 month pic 99. 15 day pic 99. 15 year pic 99.
However, database systems consider duplicate names an error. Thus, if more than one field in a particular file has the same name, you receive a compile error when the ".xfd" file is generated.
The solution to this situation is to add a NAME directive that associates an alternate name with one or both of the conflicting fields. (See section 6.3.7 for more information.)
Voice: (800) 262-6585 (U.S.A. and Canada)
Voice: (858) 689-4500
Fax: (858) 689-4550
Please share your comments on this manual
or on any Acucorp documentation with the
Acucorp Communications Department.
|© 1988-2003 Acucorp, Inc.|
All rights reserved.