The LOAD option of the CA-Datamacs/II interface is designed to load tables into a database, using a flat file as the source of the data. Field generators can be used concurrently to mask out sensitive data or otherwise generate more comprehensive test data within the existing input records. The source of the data input file would most likely be the output file of a previous CA-Datamacs/II UNLOAD job. For each record read, only one record can be added to a table.
There are two types of CA-Datamacs/II LOADs; an automatic load and a manual load. The automatic load requires the least amount of coding because statements directing the load are embedded in the input file and are a by-product of the UNLOAD process. Conversely, the statements directing the manual load must be coded in the CA-Datamacs/II job.
Whenever more than one table is to be loaded in the same run, the input file must contain special control information to direct CA -Datamacs/IICA-Datamacs/II to add the subsequent records to the specified table. This special control information is attached to each data record as a 12 byte prolog. The prolog contains the 3-character internal table name (DATACOM-NAME) and a pointer to the last byte of the data record plus one, relative to zero
When the prolog is not available, it must be added prior to LOADing the records. This can be accomplished with the CA-Datamacs/II DCL CREATE and/or CONVERT functions, or a user program.
To indicate a manual load to CA-Datamacs/II, simply code a START statement immediately following the *DM DATACOM statement, followed by the CA-Datamacs/II commands to direct the load. CA-Datamacs/II will only add the record if a paragraph name matching the table name and an ADDIT command have been coded.
For an automatic load, do not code a START statement and do not code any CA-Datamacs/II commands or paragraph names. Just code the DATACOM and COPY TABLE statements.
For both an automatic and a manual load, the DATABASE occurrence name and COPY TABLE information must be coded to direct CA-Datamacs/IICA-Datamacs/II to retrieve the table record descriptions to be used in this run. Using a different Datadictionary is also allowed. It is the users responsibility to insure the record description copied from Datadictionary correctly defines the data for both the UNLOAD and subsequent RELOAD functions.
Another use of the manual load is to load data from specific tables, even though the input file may contain records from many tables. A paragraph name equal to the COPY TABLE name is coded. Each input record has the table name associated with it. By coding a paragraph name equal to the table occurrence name and including an ADDIT command in that paragraph, the record will be added, otherwise, it will be bypassed. This is a useful technique when one test table out of many must be refreshed during the testing phase.
If there is a requirement to add a record only when a key in another table or tables is present, the manual LOAD provides the facility to code such logic. For example, a LOCATE command with a keys file and a NOT-FOUND GO TO paragraph name to bypass the ADDIT.
A subset of this technique may be specified during the UNLOAD by APPENDing READ equal commands to the output record. However, there are restrictions. See the WRITE command for more information.
The sequence of events for an automatic load are:
If any errors are detected, terminate the job.
If it is successful, read the next DMIFILE input record. Loop from step 2 until EOJ.
If it is a duplicate, print a message, bypass the add, and read the next record.
If it is any other error, print a message and terminate the job.
For a manual LOAD, the only difference is, after reading the input record and applying any field generators, a search is done to see if a paragraph name equal to the table occurrence name was coded. If it was not, then the input record is bypassed. If it was, then any commands specified in the paragraph will be executed. The record will only be added if an ADDIT command is coded in the paragraph.
The following example illustrates using CA-Datamacs/II to automatically LOAD a single CA-DATACOM/DB database table. Note the absence of a START statement and any other commands and paragraph names.
*DM TBLSZE IS 10.
IDENTIFICATION DIVISION.
PROGRAM-ID. Datamacs.
AUTHOR. CA-DATACOM/DB INTERFACE.
REMARKS. LOAD DESIGN
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*DM GENERATE ALL RECORDS.
*DM PRINT ALL RECORDS.
*DM DATACOM LOAD DATABASE NAME IS x-------------------------x
*DM CHECKPOINT EVERY number-of-recs RECORDS
*DM BACKOUT.
*
DATA DIVISION.
WORKING-STORAGE SECTION.
*
*DM COPY TABLE NAME IS EMPLOYEE
*DM ELEMENT element-name
*DM SUPPRESS.
*DM END-COPY.
*
PROCEDURE DIVISION.
Programming Notes:
This CA-Datamacs/II run will automatically load records from an input file (DMIFILE) into the table specified. Assume the input file was previously created by a CA-Datamacs/II UNLOAD job.
The records can be checkpointed if the number of records is specified.
Because BACKOUT is coded, the load will be undone back to the last checkpoint at end-of-job. The use of BACKOUT in this example serves as an illustration only, and probably would not be coded in a real LOAD.
| Copyright © 2009 CA. All rights reserved. | Tell Technical Publications how we can improve this information |