In order to define one or more alternate keys for a file use the following procedure.

1.        At PROIV File Maintenance define the physical record layout in the usual way, and then for the first alternate key continue as follows.

2.        Mark the beginning of the alternate key definition by defining the next entry as a Mapped Start entry by giving it a DATA TYPE of MS and VARIABLE NAME of filename.  Press <Return> only, at the remaining fields for this record.

3.        In the next VARIABLE NAME field, enter a full or partial variable name to make up the whole or a part of the alternate key.  Press <Return> only, at the remaining fields for this record.

4.        Variables used in alternate keys must be of DATA TYPE 'A' and EXTERNAL TYPE 'ALPHA'.

5.        Repeat step 3 for any remaining parts of the alternate key in order.

6.        Mark the end of the alternate key definition by defining the next record as a Mapped End record ME.  Press <Return> only, at the remaining fields for this record.

7.        If more than one alternate key is to be defined, repeat steps 2 to 5 for each one. 

8.        End the file definition in the usual way.

Example

This example shows how to access a CUSTOMER file by each of three alternate keys, the first two of which have duplicates and so cannot be used where an individual record is to be accessed uniquely by key.  The first screen shows the CUSTOMER file definition (which includes the alternate key definitions) and the remaining screens show typical examples of the alternate keys' usage.

 

PTI      @DOCFIL             PROIV Technologies             12/06/91  14:20   PAGE 1
TRM:     CONSOLE          F I L E  D O C U M E N T A T I O N                  OPR:  SYS
                            CO-    AUTO-       EXTERNAL     FILE          KEY     RECORD
                            DIV  SEQUENCED   RECORD FORMAT  TYPE        LENGTH    LENGTH
FILE NAME:  CUSTOMER                               Y                       10      109
ALTERNATE:                                                  RECORD CODE:
DESC:  CUSTOMER MASTER FILE
-------------------------------R E C O R D  L A Y O U T---------------------------------
    DATA                                     MAX FILL                   SPECIAL    ARRAY
SEQ TYPE             VARIABLE NAME           LEN CODE DISPLAY-CODE       CHECK     SIZE
--- ---- ----------------------------------- --- ---- ------------      -------    -----
001 K       CUST.NO                           10
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
002 A       CUST_NAME                         30
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
003 A       CUST_ADDR                         30
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
004 A       CUST_CITY                         25
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
005 A       CUST_STATE                         2
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
006 A       CUST_POST                          9
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
007 A       CUST_SLSMN                         3
            EXTERNAL TYPE  ALPHA       STORAGE FORMAT                   ENCRYPTED
008 MS      SLSCUST
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
009 M       CUST_SLSMN                         1                                     3
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
010 ME
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
011 MS      POSTCUST
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
012 M       CUST_POST                          1                                     5
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
013 M       CUST_NAME                          1                                    10
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
014 ME
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
015 MS      POSTCUSU
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
016 M       CUST_POST                           1                                     9
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
017 M       CUST.NO                             1                                    10
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
018 ME
            EXTERNAL TYPE              STORAGE FORMAT                   ENCRYPTED
 

Figure 24. File Documentation: Record Layout Screen

 

001 CUST_NO - This is the primary key to the physical file CUSTOMER.

008 - This is an MS type entry that marks the start of the definition of alternate key 1. SLSCUST is the alternate key definition name.

009 - This is the only M type entry in this alternate key definition.  It specifies that the entire salesman id is the alternate key 1

010 - This is a ME type entry that marks the end of the definition of alternate key 1.

011 - This is an MS type entry that marks the start of the definition of alternate key 2. POSTCUST is the alternate key definition name.

012 - This is the first of two M type entries in this alternate key definition.  It specifies that the first five characters of the zip code make up the first portion of alternate key 2.

013 - This is the second M type entry.  It specifies that the first ten characters of the customer name makes up the final portion of alternate key 2.

014 - This is a ME type entry that marks the end of the definition of alternate key 2.

015 - This is an MS type entry that marks the start of the definition of alternate key 3.  This key will always be unique because it contains the primary key field CUST_NO.  POSTCUSU is the alternate key definition name.

016 - This is the first of two M type entries in this alternate key definition. It specifies that the entire zip code make up the first portion of alternate key 3.

017 - This is the second of the two M type entries.  It specifies that the complete customer number makes up the second portion of alternate key 3.

018 - This is  ME type entry that marks the end of the definition of alternate key 3.

The following three functions illustrate how to access the customer file by each of the alternate keys.

Comment on this topic

Topic ID: 720166

 
 
 

Table of Contents

Index

Glossary

-Search-

Back