Appendix E
The Common Data Dictionary
This appendix describes the Common Data Dictionary (CDD).
The CDD is a set of shareable data definitions (language-independent structure declarations) that are defined by a system manager or data administrator. CDD provides a central repository that can be shared and that is protected from unauthorized access. The definitions stored in CDD help the system manager coordinate an effective data-management system.
Using CDD has two advantages:
Record declarations are language independent.
A single declaration helps guarantee the accuracy and reliability of data.
The CDD is a layered product available from Oracle, and not all systems that use PL/I use the CDD. Therefore, PL/I CDD support is only meaningful if CDD is on your system. To determine if it is installed, see your system manager.
CDD data definitions are organized hierarchically in much the same way that files are organized in directories and subdirectories. For example, a dictionary for defining personnel data might have separate directories for each employee type. A directory for salespeople might have subdirectories that would include data definitions for records such as salary and commission history or personnel history.
CDD entries are stored as an internal form; descriptions of data definitions are entered into the dictionary in a unique, general-purpose language called Common Data Dictionary Language (CDDL), and the CDDL compiler converts the data descriptions to an internal form, making them independent of any higher-level language. When a program is compiled, CDD data definitions are drawn into higher-level language programs (provided the data attributes are consistent). Program listings include CDD data definitions in the same language as the application program.
The following examples illustrate how data definitions are written for the CDD. The first example is a structure declaration written in CDDL. The second example shows the same structure as it would appear in a PL/I listing.
Example 1
PAYROLL_RECORD STRUCTURE.
SALESPERSON STRUCTURE.
NAME DATATYPE IS TEXT 30.
ADDRESS DATATYPE IS TEXT 40.
SALESPERSON_ID DATATYPE IS UNSIGNED NUMERIC 5.
END SALESPERSON STRUCTURE.Example 2
DECLARE 1 PAYROLL_RECORD, 2 SALESPERSON, 3 NAME CHARACTER(30), 3 ADDRESS CHARACTER(40), 3 SALESPERSON_ID PIC '(5)9';
The CDD provides two utilities for creating and maintaining a dictionary:
The Dictionary Management Utility (DMU), for creating and maintaining the CDD's directory hierarchy, history lists, and access control lists
The Dictionary Verify/Fix Utility (CDDV), for repairing damaged dictionary files
DMU commands create directories and define record paths. Once these paths are established, records can be included and used in PL/I programs with the %DICTIONARY statement. For a detailed description of the %DICTIONARY statement, see the Endless PL/I for OpenVMS Reference Manual.
At compile time, CDD record and its attributes are extracted from the designated CDD record node; then the record's corresponding PL/I declaration is entered into the object module.
E.1. PL/I and CDDL Data Types
The CDD supports some data types that are not native to PL/I. If a data definition contains an unsupported data type, PL/I makes the unsupported data type accessible by declaring it as data type BIT_FIELD or BYTE_FIELD. PL/I does not attempt to approximate a data type that is not supported by PL/I. For example, an F_FLOATING_COMPLEX number is declared BYTE_FIELD(8), not (2)FLOAT(24).
However, the use of the BIT_FIELD and BYTE_FIELD types is limited. Data declared with these data types can be manipulated only with the PL/I built-in functions ADDR, INT, POSINT, SIZE, and UNSPEC. Variables declared with BIT_FIELD or BYTE_FIELD can also be passed as parameters provided the parameter is declared as ANY. This limits references to data declared with BIT_FIELD or BYTE_FIELD to contexts in which the interpretation of a data type is not applied to the reference.
For example:
/* Declaration supplied by programmer */ DCL 1 A BASED(P), 2 B FLOAT BINARY(24), 2 C FLOAT BINARY(24); /* Data definition supplied by CDD */ DCL 1 Q BASED, 2 X BYTE_FIELD(8); . . . P = ADDR(Q.X);
In this example, the ADDR built-in function gives the address of Q.X, which is assigned to P. Therefore, A can be used to reference X.
The following table summarizes the CDDL data types and corresponding PL/I data types. For further information on CDDL data types see the CDD documentation.
| CDDL Data Type | PL/I Data Type | Remark |
|---|---|---|
| DATE | BYTE_FIELD(8) | |
| VIRTUAL | ignored | |
| BIT n ALIGNED | BIT(n) ALIGNED | |
| BIT n | BIT(n) | |
| UNSPECIFIED | BYTE_FIELD(n) | Depending on length |
| BIT_FIELD(n) | of field | |
| TEXT | CHARACTER(n) | |
| VARYING STRING | CHARACTER(n) VARYING | |
| D_FLOATING | FLOAT BINARY | Depending on BASE |
| FLOAT DECIMAL | specified in CDDL | |
| D_FLOATING COMPLEX | BYTE_FIELD(16) | |
| F_FLOATING | FLOAT BINARY | Depending on BASE |
| FLOAT DECIMAL | specified in CDDL | |
| F_FLOATING COMPLEX | BYTE_FIELD(8) | |
| G_FLOATING | FLOAT BINARY | Depending on BASE |
| FLOAT DECIMAL | specified in CDDL | |
| G_FLOATING COMPLEX | BYTE_FIELD(16) | |
| H_FLOATING | FLOAT BINARY | Depending on BASE |
| FLOAT DECIMAL | specified in CDDL | |
| H_FLOATING COMPLEX | BYTE_FIELD(32) | |
| SIGNED BYTE | FIXED BINARY(7) | |
| UNSIGNED BYTE | BYTE_FIELD(1) | |
| SIGNED WORD | FIXED BINARY(15) | |
| UNSIGNED WORD | BYTE_FIELD(2) | |
| SIGNED LONGWORD | FIXED BINARY(31) | |
| UNSIGNED LONGWORD | BYTE_FIELD(4) | |
| SIGNED QUADWORD | BYTE_FIELD(8) | |
| UNSIGNED QUADWORD | BYTE_FIELD(8) | |
| SIGNED OCTAWORD | BYTE_FIELD(16) | |
| UNSIGNED OCTAWORD | BYTE_FIELD(16) | |
| PACKED NUMERIC | FIXED DECIMAL | |
| SIGNED NUMERIC | BYTE_FIELD(n) | |
| UNSIGNED NUMERIC | PICTURE '(d)9V(s)9' | |
| LEFT OVERPUNCHED | PICTURE 'T(d)9V(s)9' | |
| LEFT SEPARATE | PICTURE 'S(d)9V(s)9' | |
| RIGHT OVERPUNCHED | PICTURE '(d)9V(s)9T' | |
| RIGHT SEPARATE | PICTURE '(d)9V(s)9S' |
PL/I ignores CDD features that are not supported by PL/I, but issues error messages when the features conflict with PL/I.
E.2. Creating CDD Structure Declarations
CDD source files must be written in the Common Data Dictionary Language (CDDL). You enter them into your file directory using a VMS editor utility, just as you would enter any other file into your directory. CDD source files should have a file type of DDL, which is the file type recognized by CDD compiler.
Once you have created a CDD source file, you can invoke the CDDL compiler to insert your record definitions in the CDD. First, however, you can define CDDL as a global symbol by issuing the following command line or including it in your login command procedure:
$ CDDL:==$SYS$SYSTEM:CDDLAfter you have done so, you need only enter CDDL to invoke CDD compiler. For example, to compile your FILE.DDL and insert it into the CDD, enter the following:
$ CDDL FILE.DDLThe CDD compiler compiles the structure declaration and issues messages, if necessary. To correct errors in your structure declaration, invoke an editor and change the data definition text as needed, and then recompile. The CDD enters only the highest version of a file; if you attempt to compile another file with the same name, CDD compiler issues an error message. However, the Dictionary Management Utility (DMU) permits updates. For further information see your CDD documentation.
E.3. Using the CDD
The %DICTIONARY statement incorporates CDD data definitions into the current PL/I source file during compilation. The %DICTIONARY statement can occur anywhere in a PL/I source file. It has the following format:
%DICTIONARY cdd-path;cdd-pathIs any preprocessor expression. The preprocessor expression is evaluated and converted to a character string, if necessary. The resulting character string is then interpreted as the full or relative path name of a CDD object. The resultant path name must conform to the rules for forming CDD path names.
There are two types of CDD path name: full and relative. A full path name begins with CDD$TOP and specifies the given names of all its descendants; it is a complete path to the record definition. Descendant names are separated from each other by a period.
A relative path name begins with any generation name other than CDD$TOP, and specifies the given names of the descendants after that point. You can create a relative path by establishing a default directory with a logical name. For example:
$ DEFINE CDD$DEFAULT CDD$TOP.PLIThis logical name definition specifies the beginning of the CDD path name; thus, a relative path name specifies the remainder of the path to the record definition. Note also that a CDD path name beginning with CDD$TOP overrides the default CDD path name. For example, if you have a record with the following path name:
CDD$TOP.SALES.JONES.SALARY
You can specify a relative path name as follows:
%DICTIONARY 'SALARY';
Or you can specify an absolute path name as follows:
%DICTIONARY '_CDD$TOP.SALES.JONES.SALARY';
The compiler extracts the record definition from CDD and inserts the PL/I structure declaration corresponding to the record description in the PL/I program.
A %DICTIONARY statement can appear as a statement by itself, or it can appear within a regular PL/I structure declaration. However, the resulting structures appear somewhat different, depending on the way %DICTIONARY is included.
If the %DICTIONARY statement is not embedded in a PL/I language statement (that is, if %DICTIONARY immediately follows a nonpreprocessor semicolon or is the first statement in the program), then the resulting structure is declared with the logical level 1, and the BASED storage attribute is furnished. The logical member levels increment from 2. For example:
DECLARE PRICE FIXED BINARY(31); %DICTIONARY 'ACCOUNTS';
would result in a declaration of the form:
DECLARE PRICE FIXED BINARY(31); DECLARE 1 ACCOUNTS BASED, 2 NUMBER, 3 LEDGER CHARACTER(3), 3 SUBACCOUNT CHARACTER(5), 2 DATE CHARACTER(12), ⋮
Notice that in the previous example, ACCOUNTS is a relative dictionary path name.
If the %DICTIONARY statement is embedded in a PL/I language statement, as in a structure declaration, then the resulting structure is declared with no logical level and no storage attribute. Logical member numbers are supplied and incremented from 100. For example:
DECLARE 1 COMMON_INTERFACES STATIC EXTERNAL, %DICTIONARY 'ACCOUNTS'; , %DICTIONARY 'ADDRESSES'; ;
Notice the syntax in this example: the %DICTIONARY statement is terminated with the usual preprocessor terminator semicolon before the normal PL/I punctuation. The normal PL/I punctuation must also be included so that the final structure declaration will contain proper PL/I punctuation. At compile time, this declaration would result in a declaration of the following form:
DECLARE 1 COMMON_INTERFACES STATIC EXTERNAL, 100 ACCOUNTS, 101 NUMBER, 102 LEDGER CHARACTER(3), 102 SUBACCOUNT CHARACTER (5), 101 DATE CHARACTER(12), ⋮ 100 ADDRESSES, ⋮
When you extract a record definition from the CDD, you can choose to include this translated record in the program's listing by using the /LIST/SHOW=DICTIONARY qualifiers on the PLI command line.
CDD data definitions can contain explanatory text in the CDDL DESCRIPTION IS clause. If you specify /SHOW=DICTIONARY, this text is included in the PL/I listing comments. You can use these comments to indicate the data type of each structure and member. The punctuation for CDDL comments is the same as for other PL/I programs.
Even if you choose not to list the extracted record, the names, data types, and offsets of CDD record definition are displayed in the program listing's allocation map.