KSDS example

The example in Figure 1 shows a sample program (CCNGVS2) with two functions from an employee record entry system with a mainline driver to process selected options (display, display next, update, delete, create). The update routine is an example of KSDS clusters, and the display routine is an example of both KSDS clusters and alternate indexes.

For these examples, the clusters and alternate indexes should be defined as follows:
  • The KSDS cluster has a record size of 150 with a key length of 4 with offset 0.
  • The unique KSDS AIX® has a key length of 20 with an offset of 10.
  • The non-unique KSDS AIX has a key length of 40 with an offset of 30.
The update routine is passed the following:
  • data_ptr, which points to the information that is to be updated
  • orig_data_ptr, which points to the information that was originally displayed using the display option
  • A file pointer to the KSDS cluster
The display routine is passed the following:
  • data_ptr, which points to the information that was entered on the screen for the search query
  • orig_data_ptr, which is returned with the information for the record to be displayed if it exists
  • File pointers for the primary cluster, unique alternate index and non-unique alternate index

By definition, the primary key is unique and therefore the employee number was chosen for this key. The user_id is also a unique key; therefore, it was chosen as the unique alternate index key. The name field may not be unique; therefore, it was chosen as the non-unique alternate index key.

The JCL in the sample code (CCNGVS3) in Figure 2 can be used to test the example code in Figure 1.