Date-sensitive processing

Occasionally you may have a need to implement different business rules based on a date. tableBASE provides for date-sensitive processing when the following rules are followed:

  1. The table must be defined and organized as ascending.
  2. Date-sensitive processing can only be used with retrieval commands: FC, FK, FG, FN, GF, GN, GP and GL.
  3. To indicate that you wish to process rows based on tableBASE‘s Date-Sensitive Processing feature, use the FUNCTION-ID field in the COMMAND-AREA. For more information see 13. FUNCTION-ID (halfword binary).
  4. Each row in the table must contain both an effective date (specifying when the rule is to become active) and an expiration date (specifying the last day the rule is active). Both these date fields must be in the format YYYYMMDD.

    The effective date is the last 8 bytes of the key. The expiration date is the first 8 bytes following the effective date.

  5. The key length of the table must include the length of the effective date field.
  6. If you wish to specify the date against which the effective and expiration date will be checked (baseline date), you can do so using the DATE field in the COMMAND-AREA. The default is the current system date. For more information see 14. FUNCTION-AREA: DATE (8 bytes).
Note:
For backward compatibility, the DATERTNX switch controls the value placed in the Found Code for a Fetch by Count operation on a date-sensitive table. For more information see Date-Sensitive Processing Found Code.

When the FUNCTION-ID field in the COMMAND-AREA indicates that Date-Sensitive Processing is operational and a retrieval command is executed that uses a key (FK, FG, FN), the search key is created by replacing the effective date with the DATE field from the COMMAND-AREA. The next row returned will be the row that has a key greater than or equal to the created key and an expiration date that is less than or equal to the date in the command area.

In commands that do not require a key to retrieve the row, such as Fetch by Count (FC), or the various Get commands (GF,GN,GP,GL), no key is used and the row returned is based on the command used and the subset of date-applicable rows in the table. For example, a GN used in conjunction with Date-Sensitive Processing will return the next row for which the DATE field in the COMMAND-AREA is greater than or equal to the effective date and less than or equal to the expiration date.

Note:
The default date used by Date-Sensitive Processing rolls over at midnight.

Figure 91 below displays some sample rows that illustrate the arrangement of the keys required for date-sensitive processing, as described above.

Figure 91. Keys required for date-sensitive processing
Keys required for date-sensitive processing