Associative Access Method
Associative access method (AAM) files allow the user to process logical records based on collective key' information. Similar to ISAM, this method uses a control file (AAM file) to determine which logical record is processed based upon the key information specified. Unlike ISAM, AAM does not require a complete or specific key. However, the key information must have been extracted from data written within the logical record.
Note the following:
A physical text file that has an associated AAM key file may be read physically sequential or random, key sequentially (forward or backwards) or through a specific key. However, logical records may only be written, updated or deleted in the physical text file through the AAM key file.
An attempt to retrieve a logical record using a key that has not been previously written to the AAM file fails with the OVER Condition Flag set to TRUE.
If fixed length records are used, the sector size (as defined using the BUFFER/FIX/FIXED declaration parameter) must be equal to or greater than the declared fixed record length. Any records written that are other than the declared fixed record length size (shorter or longer) is padded (with the LESS Condition Flag set TRUE if record locking is not in effect) or truncated (with the OVER Condition Flag set TRUE), as appropriate. In addition, deleted record space is automatically re-used on AAM files with fixed record lengths.
A physical text file may have more than one key file (AAM and/or ISAM) associated with it. However, caution should be exercised when processing physical text files with more than one key file associated with it to insure adjustments are made to each affected key file when any processing is performed.
Up to 95 different key fields may be specified during an AAM file's creation. Each of the key fields may be up to 16383 bytes long and they may be specified as being any of the data within the logical record.
A search for matching logical records may be made using the following techniques:
|
Value |
Match |
|
X |
Exact, key information must exactly match the specified key field (like ISAM). |
|
F |
Free, key information may be contained anywhere within the specified key field. |
|
L |
Left, key information must be in the left most bytes of the specified key field. |
|
R |
Right, key information must be in the right most bytes of the specified key field. |
At least one non-null key specification is necessary for the first READ operation since an AAM file has been opened. After this criteria has been met, subsequent READ operations using all null key information rereads the previously retrieved logical record.
The same key field may be searched using more than one technique in a READ instruction (i.e., both a Left and a Free search; both a Right and Free, etc.).
Upon successful retrieval of a record, subsequent records that also match the search criteria may be accessed using the READKG instruction. After at least one successful READKG instruction, the search may be resumed in reverse order (re-reading previously read records) using the READKGP instruction.
Logical records may be updated in place (key information is automatically updated).
The AAM key file requires 64K for every 2048 logical records in the physical text file.
It is possible to interrupt out of an AAM READ, READLAST, READKG, or READKGP instruction via a trapped function key. The current position in the file is maintained so that a READKG or READKGP may be issued if nothing else is done to the file. If you desire to continue reading from where you interrupted the AAM process, you should make the READKG or READKGP the last instruction in the trapped routine, just prior to the normal RETURN instruction.
See Also: Sequential Access Method, Random Access Method, Indexed Sequential Access Method, Disk I/O Instructions
![]() |