Data Retrieval Logic for DATACOM

In this section:

This section describes the three types of DATACOM record retrieval commands generated by the Adapter for DATACOM:

Note: Sequential retrieval commands are used under each of the following circumstances:


Top of page

x
GSETL and GETIT

When the adapter determines sequential retrieval needs to be done for the root segment, it issues a GSETL command. It uses the KEYNAME, specified in the Access File, and establishes the starting position at the beginning (lowest value) of the key. Only one GSETL command is issued per request.

GETIT commands follow the GSETL command. They retrieve the element(s) for each root record indexed by the key. The adapter requests only the elements necessary to satisfy the request. If there are no sort fields in the request, the answer set is produced, in ascending order, by the key. GETIT commands are issued repeatedly until DATACOM issues a return code of 19 (End of Table).

As long as the KEYNAME in the Access File is the Native Key, the adapter retrieves all records that correspond to a DATACOM table.


Top of page

x
GSETP and GETPS

Only one GSETP command is issued per request. GETPS commands follow the GSETP command. They retrieve the element(s) for each root record by physical layout in the database. GETPS commands are issued repeatedly until DATACOM issues a return code of 19 (End of Table).


Top of page

x
SELFR and SELNR

The adapter uses two types of selection criteria to construct the SELFR call to DATACOM for a record:

  1. All the values supplied in WHERE statements that mention a field in the segment and have any of these types of operators:

    EQ
    IS
    GE
    GT
    LE
    LT
    NE
    CONTAINS
    FROM...TO
     

    Note: The SELFR request does not use selection on defined fields.

  2. DBA value selection criteria on the segment.

The adapter generates a SELFR command, using all available selection criteria on the segment. This builds a list of records which match the selection criteria and returns the first record. The list is built in the temporary index area of the DATACOM data source.

For a descendant record with SEGTYPE=U, the SELFR retrieves the unique descendant. No SELNR command is issued. Otherwise, the SELFR command is followed by SELNR command(s) which retrieve the records listed in the temporary index. A SELNR is issued repeatedly until DATACOM issues a return code of 14 (End/Beginning of Set).

Note: An additional selection command, SELST, enables you to interrupt record selection if records are rejected from the index based on the REJECTLIMIT attribute in the Access File. For related information, see FOUNDLIMIT and REJECTLIMIT in Access File Attributes.



Example: Using a Sequence of Calls for a Multi-Segment Request

To illustrate the sequence of calls the adapter must make to DATACOM to service a multi-segment request, we will use the PERSPAY data source.

Master File PERSPAY

FILENAME=PERSPAY, SUFFIX=DATACOM , $
 SEGMENT=PERSON, SEGTYPE=S0, $
  FIELDNAME=NUMBER_PERS,     ALIAS=EMDTA.0000, USAGE=P5,   ACTUAL=Z5, $
  FIELDNAME=NAME,            ALIAS=EMDTA.0001, USAGE=A24,  ACTUAL=A24, $
  FIELDNAME=STREET_ADDRESS,  ALIAS=EMDTA.0002, USAGE=A24,  ACTUAL=A24, $
  FIELDNAME=CITY_ADDRESS,    ALIAS=EMDTA.0003, USAGE=A15,  ACTUAL=A15, $
  FIELDNAME=STATE_ADDRESS,   ALIAS=EMDTA.0004, USAGE=A2,   ACTUAL=A2,  $
  FIELDNAME=ZIP_CODE_LOC,    ALIAS=EMDTA.0005, USAGE=A5,   ACTUAL=A5,  $
  FIELDNAME=SOCIAL_SECURITY, ALIAS=EMDTA.0006, USAGE=P10,  ACTUAL=P5,  $
 SEGMENT=PAYROLL, SEGTYPE=S0, PARENT=PERSON, $
  FIELDNAME=NUMBER_PAY,      ALIAS=PAYRC.0000, USAGE=P5,   ACTUAL=Z5, $
  FIELDNAME=ACTIVITY_CODE,   ALIAS=PAYRC.0001, USAGE=A1,   ACTUAL=A1,  $
  FIELDNAME=ACTIVITY_STATUS, ALIAS=PAYRC.0002, USAGE=A1,   ACTUAL=A1,  $
  FIELDNAME=CURRENT_RATE,    ALIAS=PAYRC.0003, USAGE=P9.2, ACTUAL=Z8,  $
  FIELDNAME=YTD_WAGES,       ALIAS=PAYRC.0004, USAGE=P9.2, ACTUAL=Z8,  $
  FIELDNAME=YTD_COMMISSION,  ALIAS=PAYRC.0005, USAGE=P9.2, ACTUAL=Z8,  $
  FIELDNAME=YTD_TAX,         ALIAS=PAYRC.0006, USAGE=P9.2, ACTUAL=Z8,  $

In the following request

SELECT NAME, NUMBER_PERS, SOCIAL_SECURITY, YTD_WAGES, YTD_COMMISSION,
   YTD_TAX
FROM PERSPAY
WHERE ACTIVITY_STATUS = 'A';

PERSON is a referenced segment; it is the root of the accessed subtree. NAME, NUMBER_PERS, and SOCIAL_SECURITY are the names of fields on this segment.

However, there are no available selection criteria for the PERSON segment (ACTIVITY_STATUS is a field on the PAY segment). Therefore, the adapter will first issue a GSETL command for the PAYROLL MASTER File (PMF), using the NUMBER_PERS Native Key. The GSETL command is followed by a GETIT command to retrieve the first root record, the EMDTA element.

Since the server always processes from top-to-bottom, left-to-right, all the related descendants of this first root record must be retrieved before proceeding to the next root record.

Next, to generate the SELFR call to retrieve PAY data source records related to the PERSON parent, two pieces of selection criteria will be used: the value of NUMBER_PERS (the KEYFLD) from the PMF record, and the selection criteria on ACTIVITY_STATUS.

The first SELFR call to DATACOM for the first root record will retrieve a PAY record with NUMBER_PAY equal to NUMBER_PERS, and ACTIVITY_STATUS equal to 'A'. Subsequent SELNR calls (SEGTYPE=SO) may retrieve other records with those same values.

After DATACOM returns a 14 for the PAY data source, a second GETIT command will be generated for a PMF record. The value of this record's NUMBER_PERS field is used, with ACTIVITY_STATUS EQ A, to generate a new set of SELFR/SELNR calls to retrieve related PAY records.

This process will be repeated until DATACOM returns a 19 for the GETIT command on the root, signifying that all records have been retrieved and processed. If the request were

SELECT NAME NUMBER_PERS SOCIAL_SECURITY YTD_WAGES YTD_COMMISSION YTD_TAX
FROM PERSPAY
WHERE ACTIVITY_STATUS = 'A' AND
STATE_ADDRESS IN ('CT', 'RI', 'MA', 'VT', 'NH', 'ME';

SELFR/SELNR commands would be issued instead of GSETL/GETIT commands, with the five STATE_ADDRESS values (STATE_ADDRESS is a field on the PERSON segment). The process however, would be the same.

Finally, keep in mind:


iWay Software