RSNs and AA Values as Keys

If DBEngine does not find a suitable index, the Client tries to use the RSN (record sequence number) or the AA Value (absolute address) of the records as the key. Both of these items are A-Series words (48-bit quantities). They are passed to the Client as part of the record header. Both use the same entry in the header, and DBEngine informs the client about what this item represents, as explained below. If the Client decides to use one of these quantities as the key, the set_name column is set to aa_set in the DATASETS client control table. Otherwise, this column is left blank, indicating that there is no set usable as an index.

The DATABridge Client can represent AA Values (or RSNs) the following ways:

  • CHAR(12), where each character is the hexadecimal representation of the correspond digit (half-byte) in the A-Series word. This is the default.
  • BINARY(6), a binary quantity that uses 48-bits where each byte in the A-Series word is represented by a byte in the relational database. See use_binary_aa.
  • Using numeric fields to hold the AA Values (or RSNs). In this case the DATABridge Client uses an appropriate numeric data type to hold the AA Values (or RSN), mainly, BIGINT for SQL Server, NUMBER(15) for Oracle and DECIMAL(15) for DB2. See use_decimal_aa.

    Note: If a DMSII SET with the NO DUPLICATES ALLOWED attribute exists or the data set has an RSN, it is recommended that you use one of these keys rather than declaring a DBGenFormat primary key.

RSNs are unique serial numbers that get assigned to records when they get created and remain associated with the record for the life of the record. You must have DMSII XE to be able to use RSNs. Furthermore, you must explicitly enable RSNs in the DASDL. If you explicitly add a column to a data set whose value is the RSN, the DATABridge Client will allow you to use this column as an RSN rather than a REAL. In such cases you should create a composite key that uses the column containing the RSN as the key. Furthermore, you should set the di_option bit DIOPT_Clone_as_RSN in the corresponding DMS_ITEMS table entry to make the client treat this item (which will be a REAL) as an RSN. See DMS_ITEMS.

AA values are the absolute address (that is, the file address — offset within the file — of the records in the data set). They do not remain constant over time; however, in the following cases, AA_values are required to implement foreign keys to link records in related data sets:

  • Any data set that contains one or more embedded data sets must always use AA values as the key. Embedded data sets use Parent_AA values to implement the link to their parent structures. In this case, DBEngine will use AA Values regardless of whether there is a SET that qualifies for being used as an index, or whether an RSN exists.
  • When an active data set has links to another data set, the latter must use AA values as the key. DBEngine uses valid AA values as keys.

Not all data sets have valid AA values; for example, ORDERED and COMPACT data sets do not have valid AA values. When AA values are used as the key, the set_name column of the DATASETS client control table is set to the name "aa_set". The name "aa_set" causes the RSN or the AA value to be used as part of the index using a column named my_rsn or my_aa depending on whether this is an RSN or an AA Value.

To find out if a data set has an RSN or a valid AA value, you need to look at the misc_flags column of the entry for the data set in the DATASETS client control table. The bit DSFLG_Static_AA (bit mask 64) is used to indicate whether the client is using an RSN or an AA Value (1 indicates RSN and 0 indicates AA Value). The bit DSFLG_Valid_AA (bit mask 128) is used to indicate whether or not the data set has a valid AA value (1 indicates a valid AA value). The client has no control over the selection of RSNs versus AA Values. This decision is made by DBEngine.

The advantage of using the AA value to generate a unique key is that it makes updates possible for data sets that could not otherwise be updated; however, this value is not an absolute constant. Any DMSII reorganization (record conversion, file format, or garbage collection) changes these values. When the AA values change, you must reclone all data sets that use the AA value as a key. Therefore, it is recommended that you consider creating a unique composite key rather than using AA values.

The DATABridge Client recognizes the names "aa_set", "user_set", and "pk_set" as special names (the use of the underscore is not allowed in DMSII names).