Partial-Record I/O


In order to increase performance associated with very wide RDBMS tables, you can specify either a file name or a field name when using any of these statements:

·    READ

·    READNEXT

·    BEG READ and END READ

·    WRITE

·    REWRITE

If a file name is specified, APPX operates on the entire record. If a field name is designated, the I/O statement operates on the named field only. If the field is a group header, the I/O will be performed on all members of the group. Using this feature limits the amount of data transferred between APPX and an RDBMS. For example, if you know that a particular section of ILF code needs to update only one or two fields within a record, you can change the I/O statements to refer to those fields only.

Traditional method:

          BEG READ TAR CUSTOMER               HOLD 1 KEY IS  CUSTOMER NO
          COMPUTE  TAR CUSTOMER CREDIT LIMIT      *      1.05
          REWRITE  TAR CUSTOMER
          END READ TAR CUSTOMER

Using Partial-Record I/O:

          BEG READ TAR CUSTOMER NO + CR LIMIT HOLD 1 KEY IS  CUSTOMER NO
          COMPUTE  TAR CUSTOMER CREDIT LIMIT      *      1.05
          REWRITE  TAR CUSTOMER CREDIT LIMIT
          END READ TAR CUSTOMER NO + CR LIMIT

In the above example, the field CUSTOMER NO + CR LIMIT is a group header field containing synonyms of both the CUSTOMER NO and CUSTOMER CREDIT LIMIT fields.

When you WRITE a single field (or group field as shown above), APPX will write NULL values into the remainder of the record. When you READ (or READNEXT or BEG READ) a partial record, the remainder of the record will contain NULL values. If you REWRITE a partial record, the remainder of the record is not modified.

Other considerations:

·    Even though the END READ statement allows you to specify a field name, this is for consistency purposes only and is not actually used other than to indirectly identify the file name so that the END READ can be associated with the appropriate corresponding BEG READ statement.

·    REWRITE statements allow you to specify either a file or field name. If a field name is specified, only the named field or group of fields will be updated. All other values in the record being updated remain unchanged. The field name specified on the REWRITE statement does not need to be the same as the field name specified on the READ statement used to retrieve the record. The entire record can be read with hold by specifying a file name on the READ statement but just a single field can be updated by specifying that field name on the REWRITE statement. Or, you can READ a group of fields and REWRITE a subset of that group of fields.

·    Partial-Record I/O only reads the field or group of fields specified. The key field specified on the READ statement is not read unless the key field is included in the group of fields specified on the READ statement. If the key field must be read, remember that a SYNONYM for the key field can easily be included in any group that you may define in the Data Dictionary. The object of Partial-Record I/O is to dramatically decrease the amount of data being retrieved and updated, therefore key fields that are not part of the READ statement are not retrieved.

·    The READNEXT statement allows a field name to be entered (instead of a file name). However, that field name is not really used to restrict the set of fields retrieved from the RDBMS server. Because APPX is generating SQL statements as it executes, a “select <column-list> from <table> where <beg-at-constraints> and <end-at-constraints>” statement is generated when a BEG READ/END READ loop is executed. Executing that select statement causes the RDBMS to generate a record set that contains all of the selected columns for each selected record. The READNEXT statement (and the END READ statement, as well) cannot change the record set, it can only retrieve the next row from that record set. Therefore, the field name supplied to a READNEXT or END READ statement is for consistency purposes only. You cannot use a READNEXT statement to change which columns are present in the record set.