3 2 3 Field Key Position

LANSA Technical

3.2.3 Field Key Position

Specify if the field is assigned a key position so that it is included to form the primary key of the file. 

Fields that form the primary key of the file should be listed first key in hierarchy (most significant key) to last key in the hierarchy (least significant key).

Rules

  • The primary key of a file (which is composed of all the fields in the key concatenated in the order specified) must be UNIQUE.
  • Sequence numbers must be consecutive.
  • The sequence number is automatically assigned when a key field/value is added. Sequence number is updated when the order of the key is updated in the list of keys.

Platform Considerations

  • IBM i: No more than one record in a file can have any given primary key. This rule is enforced by features in the operating system (DDS keyword UNIQUE) and can never be violated. Attempting to add a record to a file with the same primary key as a record already in the file will result in a "duplicate key error".

Tips & Techniques

  • There is no requirement to specify a primary key when setting up a file definition, but it is strongly recommended that each file be set up with a key.
  • LANSA automatically handles duplicate key errors and there is no need for user logic to handle or check for them.
  • The existence of a unique primary key is important to LANSA because it uniquely identifies one and only one record in a file.
  • Field key position is not related to 3.2.2 Field Sequence. However, the key fields are typically the first fields listed in the file.

Also See

3.2.2 Field Sequence

Ý 3.2 Real Fields in File