Product Documentation

FairCom RTG COBOL User Guide

Previous Topic

Next Topic

Multi-Record Example

This is an example of using multiple records with SQL. Notice that CARD-TABLE-PLATINUM redefines a previous record structure, but it includes additional fields. This means that this table has two different types of records, with different sizes. FairCom RTG can handle this properly, as long as you indicate the rules that the SQL server needs to use to decide which record belongs to which table. To do this, use the following XDD directive:


*>>XDD WHEN ELITE-MEMBER-TYPE != "P" TABLENAME="REGULARMEMBERS"

05 CARD-TABLE.

This will instruct FairCom RTG to create two separate SQL tables representing each separate set of records, depending on the condition that has been established for values within each record.

Notice that physically there is still a single COBOL file which allows you to run your COBOL programs with no modification. FairCom RTG handles this dynamically, building SQL tables as if they were actually views, and updating the indexes in accordance with the file definition.

In this example, we are forcing FairCom RTG to create a separate table to represent Platinum members. This SQL table includes some additional fields that are not displayed for the regular table.


*>>XDD WHEN ELITE-MEMBER-TYPE="P" TABLENAME="PLATINUMMEMBERS"

05 CARD-TABLE-PLATINUM REDEFINES CARD-TABLE.

10 GROUP-TITLE-INFO-PLT OCCURS 3 TIMES.

15 CARD-FAMILY-NUMBER-PLT.

20 CARD-LABEL-NUMBER-PLT PIC 9(4).

20 CARD-MAIN-NUMBER-PLT PIC 9(8).

20 CARD-NUMBER-CRC-PLT PIC 9(2).

*>>XDD DATE=YYMMDD

15 EMISSION-DATE-PLT PIC 9(6) COMP-6.

*>>XDD DATE=YYMMDD

15 VALID-UNTIL-DATE-PLT PIC 9(6) COMP-6.

10 GROUP-REWARDS-POINTS.

15 TOTAL-POINTS PIC 9(8).

*>>XDD DATE=YYMMDD

15 EXPIRATION-DATE PIC 9(6) COMP-6.

*>>XDD DATE=YYMMDD

15 LAST-TRANS-DATE PIC 9(6) COMP-6.

05 CARD-GROUP-NUMBER PIC 9(4).

05 CARD-EMBOSS-FLAG PIC X(1).

TOCIndex