Yes!
To represent an array of data, COBOL copybooks use the OCCURS statement.
For simple OCCURS statements,
+1Copybook automatically generates the corresponding columns.
For example, if the COBOL copybook contains:
05 CAT-OF-SERVICE PIC XXX OCCURS 5.
+1Copybook will generate:
CAT_OF_SERVICE_1 VARCHAR2(3);
CAT_OF_SERVICE_2 VARCHAR2(3);
CAT_OF_SERVICE_3 VARCHAR2(3);
CAT_OF_SERVICE_4 VARCHAR2(3);
CAT_OF_SERVICE_5 VARCHAR2(3);
For multi-column OCCURS statements,
+1Copybook does not automatically generate the corresponding columns in the
SQL*Loader control file.
Columns found within an OCCURS statement usually should be defined as a new
table in the copybook.txt file.
To handle the multi-column OCCURS statements, DBAs can do one of two things:
(1) comment out the OCCURS statement and generate the corresponding columns in the copybook.txt file
or (2) define a new table in the copybook.txt file instead.
Here's an example. Say, the copybook contains:
05 CUST-CODE-DATA
OCCURS 10 TIMES
INDEXED BY AB-CD.
10 CUST-CODE PIC X(03).
10 CUST-CODE-VALUE PIC 99999.99.
In our first approach, the DBA wishes to keep these columns in the original table.
To do this, the DBA would need to comment out the OCCURS columns and
convert the OCCURS columns in the copybook.txt file to:
/*
05 CUST-CODE-DATA.
OCCURS 10 TIMES
INDEXED BY AB-CD.
10 CUST-CODE PIC X(03).
10 CUST-CODE-VALUE PIC 99999.99.
*/
05 CUST-CODE-DATA.
10 CUST-eODE-01 PIC X(03).
10 CUST-CODE-VALUE-01 PIC 99999.99.
10 CUST-CODE-02 PIC X(03).
10 CUST-CODE-VALUE-02 PIC 99999.99.
10 CUST-CODE-03 PIC X(03).
10 CUST-CODE-VALUE-03 PIC 99999.99.
10 CUST-CODE-04 PIC X(03).
10 CUST-CODE-VALUE-04 PIC 99999.99.
10 CUST-CODE-05 PIC X(03).
10 CUST-CODE-VALUE-05 PIC 99999.99.
10 CUST-CODE-06 PIC X(03).
10 CUST-CODE-VALUE-06 PIC 99999.99.
10 CUST-CODE-07 PIC X(03).
10 CUST-CODE-VALUE-07 PIC 99999.99.
10 CUST-CODE-08 PIC X(03).
10 CUST-CODE-VALUE-08 PIC 99999.99.
10 CUST-CODE-09 PIC X(03).
10 CUST-CODE-VALUE-09 PIC 99999.99.
10 CUST-CODE-10 PIC X(03).
10 CUST-CODE-VALUE-10 PIC 99999.99.
Once all of the OCCURS statements have been converted in the copybook.txt file,
you can run +1Copybook to generate the control file.
The advantage of expanding the OCCURS columns in the copybook.txt file is there will only be one table
with all of the data.
However, the disadvantage (and it's a big one!) is the table is not designed well for future maintenance.
Say for example a change is made and instead of 10 customer code values there are now 20.
This is a problem.
The DBA can append CUST-CODEs 11 through 20 to the end of the existing table.
These columns will possibly no longer be next to the previous set of customer code values.
To make use of the new columns, the application programs must be updated.
A better solution is to extract the columns within the OCCURS statement and create a new table.
To do this using +1Copybook, you modify the copybook.txt file.
For example, the copybook.txt file can contain:
CUSTOMER_CODES TABLE
10 CUST-ID PIC X(9).
10 CUST-CODE PIC X(03).
10 CUST-CODE-VALUE PIC 99999.99.
The resulting CREATE TABLE script is:
CREATE TABLE CUSTOMER_CODES (
CUST_ID VARCHAR2(9),
CUST_CODE VARCHAR2(3),
CUST_CODE_VALUE DECIMAL(8,2)
)
Now if a change is made and 20 or 50 or 100 customer codes are added to the database,
there are no changes to the database or tables, only to the data contained in them.
And it's more than likely there will be no changes needed to the application software to
support additional customer codes.
Optionally, you can also add a counter column to the base table CUSTOMER named, say, CUSTOMER_CODES_COUNTER
which contains the number of codes defined for a specific CUST_ID.
The tables are still normalized and applications can run faster by knowing in advance whether
CUSTOMER_CODES exist for a CUST_ID.
It's one less query to run if there is no data in the CUSTOMER_CODES table.
To Top