Processing DEDBs with a secondary index

Application programs can process a secondary index for DEDB databases of either HISAM or SHISAM database structures.

A HISAM secondary index database or a SHISAM secondary index database offers sequential key secondary index support.

A DEDB database with sequential dependent (SDEP) segments can have a secondary index database. SDEP segments cannot be used as an index field. Therefore, a SDEP segment cannot have LCHILD or XDFLD statements defined under its SEGM statement. Because SDEP segments are transient data and they are deleted using SDEP SCAN and SDEP DELETE utilities, Fast Path secondary index support for SDEP segments is restricted; that is, a SDEP segment cannot be a target segment or a source segment for a secondary index database. When the target segment is a root segment, SDEP segments can be returned for a DEDB database that is accessed through its alternate sequence.

Fast Path secondary indexing supports both unique and non-unique keys. A HISAM secondary index database offers unique and non-unique key support, and a SHISAM secondary index offers unique key support only.

A HISAM secondary index database supports both unique and non-unique keys. For a HISAM secondary index database, the non-unique key support is provided using an ESDS overflow data set. Duplicate keys are stored in Last-In First-Out (LIFO) order. The first inserted duplicate key is stored in the KSDS data set and the remaining duplicate keys are stored in the ESDS overflow data set in LIFO order.

The target segment is in the primary DEDB database. The target segment is the segment that an application program needs to retrieve. The target segment can be at any one of the 15 levels in a primary DEDB database. SDEP segments cannot be a target segment or a source segment for a secondary index database.

There are a maximum of 32 secondary indexes per segment and 255 secondary indexes per DEDB database.

A Fast Path secondary index database can be accessed as:

Fast Path secondary indexes provide support for boolean qualification that are similar to full-function DL/I calls. The boolean operators supported are:
  • Logical AND (coded * or &)
  • Logical OR (coded + or |)

Restrictions

The restrictions that apply to processing DEDBs with a secondary index are:
  • A DEDB database with sequential dependent (SDEP) segments can have a secondary index database, but SDEP segments cannot be used as an index field. Therefore, a SDEP segment cannot have LCHILD or XDFLD statements defined under its SEGM statement. Because SDEP segments are transient data and they are deleted using SDEP SCAN and SDEP DELETE utilities, Fast Path secondary index support for SDEP segments is restricted; that is, a SDEP segment cannot be a target segment or a source segment for a secondary index database.
  • Fast Path secondary indexing does not support shared secondary indexes. Multiple secondary index segments support is only for DEDB implementation, and is not the same as shared secondary indexes support.
  • A Fast Path secondary index database supports only symbolic pointers. There is no direct pointer support. Using symbolic pointers for indexed segments, a Fast Path secondary index database is not impacted when its primary DEDB database is reorganized.
  • A qualified GU/GN segment name with SSA using the primary key field for target=root segment is supported when a primary DEDB database is accessed through its secondary index using a PCB with the PROCSEQD= parameter.
  • A qualified GU/GN segment name with SSA using the primary key field for target=dependent segment is not supported. An AC status code is returned for the qualified Get call when a primary DEDB database is accessed through its secondary index using a PCB with the PROCSEQD= parameter.
  • The independent AND (#) boolean operator is not supported.
  • No boolean support is provided for SSAs with XDFLD and fields from the target segment. Boolean support is only for XDFLDs.

Example 1 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access COURSE segment on a primary DEDB database through its secondary index using GU and GN DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB2NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, NAMESXDB. The COURSE segment is the target segment and it is a root segment. The source segment is the same as the target segment.

PCB2NDX
 PCB TYPE=DB,DBDNAME=EDUCDB,PROCOPT=GR,KEYLEN=100,
     PROCSEQD=NAMESXDB
 SENSEG   NAME=COURSE,PARENT=0      <<- (target seg=root)
 SENSEG   NAME=CLASS,PARENT=COURSE
 SENSEG   NAME=INSTRUCT,PARENT=CLASS
 SENSEG   NAME=STUDENT,PARENT=CLASS
 PSBGEN   PSBNAME=NAMEXPSB,LANG=COBOL
 END
PCB   PCB2NDX
GU    COURSE(NAMEINDX=CHEMISTRY)
GN    COURSE 

GU COURSE returns the COURSE segment for CHEMISTRY in the primary DEDB database using the secondary index key NAMEINDX=CHEMISTRY.

The key of the pointer segment, CHEMISTRY, is returned in the key feedback area.

GN COURSE returns the COURSE segment in the primary DEDB database that is pointed by the next pointer segment after segment CHEMISTRY in the Fast Path secondary index database, NAMESXDB.

The key of the next pointer segment after CHEMISTRY (the next sequential key after the secondary index key CHEMISTRY) in the Fast Path secondary index database, NAMESXDB, is returned in the key feedback area.

Example 2 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access COURSE segment on a primary DEDB database through its secondary index using GU and GN DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB2NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, NAMESXDB. The COURSE segment is the target segment and it is a root segment. The source segment is the same as the target segment.

PCB   PCB2NDX
GU    COURSE(NAMEINDX=CHEMISTRY)
GN                                     1st GN
GN                                     2nd GN
GN                                     3rd GN
GN                                     4th GN

GU COURSE returns the COURSE segment for CHEMISTRY in the primary DEDB database using the secondary index key NAMEINDX=CHEMISTRY.

The key of the pointer segment, CHEMISTRY, is returned in the key feedback area.

The first GN call returns the segment of the DEDB inverted structure of the CHEMISTRY COURSE segment in the primary DEDB database. Because the COURSE segment is the target segment and it is a root segment, all segments in the physical structure are accessible as defined in PCB PCB2INDX. GN returns the CLASS segment in the database record under the CHEMISTRY COURSE segment that was retrieved by the GU call in the primary DEDB database.

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

The second GN call returns the INSTRUCT segment in the database record under the CHEMISTRY COURSE segment

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment and the key of the INSTRUCT segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

The third GN call returns the STUDENT segment in the database record under the CHEMISTRY COURSE segment.

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment and the key of the STUDENT segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

Because the STUDENT segment is the last segment in the COURSE database record in the primary DEDB database, the fourth GN call returns the COURSE segment in the primary DEDB database using the next secondary index key after the CHEMISTRY segment in the secondary index database, NAMESXDB.

The key of the next pointer segment after CHEMISTRY (the next sequential key after the secondary index key CHEMISTRY) in the Fast Path secondary index database, NAMESXDB, is returned in the key feedback area.

Example 3 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access COURSE segment on a primary DEDB database through its secondary index using GU and GNP DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB2NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, NAMESXDB. The COURSE segment is the target segment and it is a root segment. The source segment is the same as the target segment.

PCB   PCB2NDX
GU    COURSE(NAMEINDX=CHEMISTRY)
GNP                                     1st GNP
GNP                                     2nd GNP
GNP                                     3rd GNP
GNP                                     4th GNP

GU COURSE returns the COURSE segment for CHEMISTRY in the primary DEDB database using the secondary index key NAMEINDX=CHEMISTRY.

The key of the pointer segment, CHEMISTRY, is returned in the key feedback area.

The first GNP call returns the first segment under the DEDB inverted structure of the CHEMISTRY COURSE segment in the primary DEDB database. Because the COURSE segment is the target segment and it is a root segment, all segments in the physical structure are accessible as defined in PCB2INDX. GNP returns the CLASS segment in the database record under the CHEMISTRY COURSE segment that was retrieved by the GU call in the primary DEDB database.

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

The second GNP call returns the INSTRUCT segment in the database record under the CHEMISTRY COURSE segment.

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment and the key of the INSTRUCT segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

The third GNP call returns the STUDENT segment in the database record under the CHEMISTRY COURSE segment.

The key of the pointer segment, CHEMISTRY, concatenated with the key of the CLASS segment and the key of the STUDENT segment under the CHEMISTRY COURSE segment, is returned in the key feedback area.

Since the STUDENT segment is the last segment in the COURSE database record in the primary DEDB database, the fourth GNP call returns a GE status code.

Example 4 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access INSTRUCT segment on a primary DEDB database through its secondary index using GU and GN DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB3NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, INSTSXDB. The CLASS segment is the target segment and it is not a root segment. The source segment (INSTRUCT segment) is not the same as the target segment (CLASS segment).

Although there are multiple LCHILD/XDFLD pairs in the CLASS SEGM statement, only one is used in this example.

DBDGEN excerpt for CLASS and INSTRUCT SEGM statements in the EDUCDB DEDB DBD:

SEGM   NAME=CLASS,BYTES=50,PARENT=COURSE
FIELD  NAME=(CLASSNO,SEQ,U),BYTES=4,START=7
FIELD  NAME=CLASNAME,BYTES=10,START=15

LCHILD NAME=(CLASXSEG,CLASSCDB),PTR=SYMB
XDFLD  NAME=CLASINDX,SRCH=CLASNAME

LCHILD NAME=(INSTXSEG,INSTSXDB),PTR=SYMB
XDFLD  NAME=INSTINDX,SEGMENT=INSTRUCT,SRCH=INSTNAME
SEGM   NAME=INSTRUCT,BYTES=50,PARENT=CLASS
FIELD  NAME=(INSTNO,SEQ,U),BYTES=6,START=1
FIELD  NAME=INSTPHNO,BYTES=10,START=11
FIELD  NAME=INSTNAME,BYTES=20,START=21

…

PSBGEN Definition for PCB3NDX:

When the target segment is not a root segment, all direct parents of the target segment from the root segment must be defined in the PCB with the PROCSEQD parameter. Only the direct parents segments along the physical path from the root segment to the target segment and all child segments of the target segment are accessible when the target segment is not a root segment. All sibling segments of CLASS are not accessible. The coding sequence of the mandatory SENSEGs must be in the sequence of the physical path of the segments (for example, from the physical root to the target) even though the segments are retrieved always in logical sequence (for example, from the target or logical root to the physical root).

PCB3NDX
 PCB TYPE=DB,DBDNAME=EDUCDB,PROCOPT=GR,KEYLEN=100,
     PROCSEQD=INSTSXDB
 SENSEG   NAME=COURSE,PARENT=0          <<- mandatory SENSEG
 SENSEG   NAME=CLASS,PARENT=COURSE      <<- mandatory SENSEG (target seg)
 SENSEG   NAME=INSTRUCT,PARENT=CLASS    <<- optional SENSEG
 PSBGEN   PSBNAME=NAMEXPSB,LANG=COBOL
 END

 PCB   PCB3NDX
 GU    CLASS (INSTINDX=TOMJONES)
 GN                                     1st GN
 GN                                     2nd GN
 GN                                     3rd GN

GU CLASS returns the CLASS segment for the instructor teaching the class, in the primary DEDB database using the secondary index key INSTINDX=TOMJONES.

The key of the pointer segment, TOMJONES, is returned in the key feedback area.

The first GU call returns the target segment of the primary DEDB database. Because the target segment (CLASS) is not a root segment, the subsequent GN returns the next segment in the DEDB inverted structure of the CLASS segment retrieved by the GU call in the primary DEDB database. For example, GN returns the COURSE segment which is a direct physical parent and also a logical child of the CLASS segment teaching the CHEMISTRY COURSE segment in the DEDB inverted structure.

The key of the pointer segment, TOMJONES, concatenated with the key of the COURSE segment, is returned in the key feedback area.

The second GN call returns the INSTRUCT segment in the database record, which is a logical child of the CLASS segment and a logical sibling of the COURSE segment in the DEDB inverted structure.

The key of the pointer segment, TOMJONES, concatenated with the key of the INSTRUCT segment is returned in the key feedback area.

Because no child or sibling segment is defined for the INSTRUCT segment in PCB PCB3NDX, the third GN call returns the CLASS segment in the primary DEDB database using the next segment in the secondary index database after INSTINDX=TOMJONES.

The key of the next pointer segment after TOMJONES (the next sequential key after the secondary index key TOMJONES) in the Fast Path secondary index database, INSTSXDB, is returned in the key feedback area.

Example 5 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access INSTRUCT segment on a primary DEDB database through its secondary index using GU and GNP DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB3NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, INSTSXDB. The CLASS segment is the target segment and it is not a root segment. The source segment (INSTRUCT segment) is not the same as the target segment (CLASS segment).

Although there are multiple LCHILD/XDFLD pairs in the CLASS SEGM statement, only one is used in this example.

DBDGEN excerpt for CLASS and INSTRUCT SEGM statements in the EDUCDB DEDB DBD:

…
SEGM   NAME=CLASS,BYTES=50,PARENT=COURSE
FIELD  NAME=(CLASSNO,SEQ,U),BYTES=4,START=7)
FIELD  NAME=CLASNAME,BYTES=10,START=15

LCHILD NAME=(CLASXSEG,CLASSXDB),PTR=SYMB
XDFLD  NAME=CLASINDX,SRCH=CLASNAME

LCHILD NAME=(INSTXSEG,INSTSXDB),PTR=SYMB
XDFLD  NAME=INSTINDX,SEGMENT=INSTRUCT,SRCH=INSTNAME


SEGM   NAME=INSTRUCT,BYTES=50,PARENT=CLASS
FIELD  NAME=(INSTNO,SEQ,U),BYTES=6,START=1
FIELD  NAME=INSTPHNO,BYTES=10,START=11
FIELD  NAME=INSTNAME,BYTES=20,START=21

…

PSBGEN Definition for PCB3NDX:

When the target segment is not a root segment, all direct parents of the target segment from the root segment must be defined in the PCB with the PROCSEQD parameter. Only the direct parents segments along the physical path from the root segment to the target segment and all child segments of the target segment are accessible when the target segment is not a root segment.

PCB3NDX
 PCB TYPE=DB,DBDNAME=EDUCDB,PROCOPT=GR,KEYLEN=100,
     PROCSEQD=INSTSXDB
 SENSEG   NAME=COURSE,PARENT=0
 SENSEG   NAME=CLASS,PARENT=COURSE      <<-- Target segment 
 SENSEG   NAME=INSTRUCT,PARENT=CLASS
 PSBGEN   PSBNAME=NAMEXPSB,LANG=COBOL
 END
 
 PCB   PCB3NDX
 GU    CLASS(INSTINDX=TOMJONES)
 GNP                                     1st GNP
 GNP                                     2nd GNP
 GNP                                     3rd GNP

GU CLASS returns the CLASS segment for the instructor teaching the particular class in the primary DEDB database using the secondary index key INSTINDX=TOMJONES.

The key of the pointer segment, TOMJONES, is returned in the key feedback area.

The first GU call returns the CLASS segment of the DEDB. Because the target segment (CLASS) is not a root segment, the first GNP returns the next segment in the DEDB inverted structure. For example, the first GNP returns the COURSE segment which is a direct physical parent, but a direct logical child, of the CLASS segment in the DEDB inverted structure.

The key of the pointer segment, TOMJONES, concatenated with the key of the COURSE segment, is returned in the key feedback area.

The second GNP call returns the INSTRUCT segment in the database record, which is a logical child of CLASS and a logical sibling of the COURSE segment in the inverted DEDB structure hierarchy.

The key of the pointer segment, TOMJONES, concatenated with the key of the INSTRUCT segment is returned in the key feedback area.

Because there is no child or sibling segment defined for the INSTRUCT segment in PCB PCB3NDX, the third GNP call under the CLASS segment with the secondary index key of TOMJONES returns a GE status code.

Example 6 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access CLASS segment on a primary DEDB database through its secondary index using GU and GN DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB4NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, CLASSXDB. The CLASS segment is the target segment and it is not a root segment. The source segment is the same as the target segment.

PSBGEN Definition for PCB4NDX:

When the target segment is not a root segment, all direct parents of the target segment from the root segment must be defined in the PCB with the PROCSEQD parameter. Only the direct parents segments along the physical path from the root segment to the target segment and all child segments of the target segment are accessible when the target segment is not a root segment.

PCB4NDX
 PCB TYPE=DB,DBDNAME=EDUCDB,PROCOPT=GR,KEYLEN=100,
     PROCSEQD=CLASSXDB
 SENSEG   NAME=COURSE,PARENT=0
 SENSEG   NAME=CLASS,PARENT=COURSE    <<-- Target segment 
 SENSEG   NAME=INSTRUCT,PARENT=CLASS
 SENSEG   NAME=STUDENT,PARENT=CLASS                    
 PSBGEN   PSBNAME=NAMEXPSB,LANG=COBOL
 END
 
 PCB   PCB4NDX
 GU    CLASS(CLASINDX=CHEM1A)
 GN                                     1st GN 
 GN                                     2nd GN 
 GN                                     3rd GN
 GN                                     4th GN

GU CLASS returns the CLASS segment for the class name, CHEM1A, in the primary DEDB database using the secondary index key INSTINDX=CHEM1A.

The key of the pointer segment, CHEM1A, is returned in the key feedback area.

The first GN call returns the COURSE segment of the DEDB inverted structure of the CHEM1A CLASS segment in the primary DEDB database. Because the CLASS segment is the target segment and it is not a root segment, GN returns the next segment in the DEDB inverted structure of the CLASS segment retrieved by the GU call in the primary DEDB database. GN returns the COURSE segment for CHEMISTRY which is a direct parent of the CHEM1A CLASS segment in the DEDB inverted structure.

The key of the pointer segment, CHEM1A, concatenated with the primary key of the COURSE segment, is returned in the key feedback area.

The second GN call returns the INSTRUCT segment in the database record under CHEM1A CLASS segment.

The key of the pointer segment, CHEM1A, concatenated with the key of the INSTRUCT segment under the CHEM1A CLASS segment, is returned in the key feedback area.

The third GN call returns the STUDENT segment in the database record under CHEM1A CLASS segment.

The key of the pointer segment, CHEM1A, concatenated with the key of the STUDENT segment under the CHEM1A CLASS segment, is returned in the key feedback area.

Because the STUDENT segment is the last segment for the CLASS segment in the database record, the fourth GN call returns the CLASS segment in the primary DEDB database using the next secondary index key after the CHEM1A segment in the secondary index database, CLASINDX.

The key of the next pointer segment after CHEM1A (the next sequential key after the secondary index key CHEM1A) in the Fast Path secondary index database, CLASSXDB, is returned in the key feedback area.

Example 7 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access class name on a primary DEDB database through its secondary index using GU and GN DL/I calls. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB4NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, CLASSXDB. The CLASS segment is the target segment and it is a not root segment. The source segment is the same as the target segment.

PCB   PCB4NDX
GU    CLASS(CLASINDX=CHEM1A)
GN    CLASS 

GU CLASS returns the CLASS segment for CHEM1A in the primary DEDB database using the secondary index key NAMEINDX=CHEM1A.

The key of the pointer segment, CHEM1A, is returned in the key feedback area.

GN CLASS returns the CLASS segment in the primary DEDB database that is pointed to by the next pointer segment after segment CHEM1A in the Fast Path secondary index database, CLASSXDB.

The key of the next pointer segment after CHEM1A (the next sequential key after the secondary index key CHEM1A) in the Fast Path secondary index database, CLASSXDB, is returned in the key feedback area.

Example 8 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I calls to access the class name on a primary DEDB database through its secondary index using GU and GN DL/I calls and C command code. For simplicity, assume that there is only one segment instance for each dependent segment.

PCB4NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, CLASSXDB. The CLASS segment is the target segment and it is a not root segment. The source segment is the same as the target segment.

PCB   PCB4NDX
GU    INSTRUCT *C (CHEM1AI12345)
GN                                     1st GN 
GN                                     2nd GN 

GU INSTRUCT returns the INSTRUCT segment for instructor number, I12345, under the CLASS segment for class name, CHEM1A.

The key of the pointer segment, CHEM1A, concatenated with the key of INSTRUCT segment, I12345, is returned in the key feedback area.

The first GN call returns the STUDENT segment of the DEDB inverted structure of the CHEM1A CLASS segment in the primary DEDB database. Because the CLASS segment is the target segment and it is not a root segment, GN returns the next segment in the DEDB inverted structure of the INSTRUCT segment retrieved by the GU call in the primary DEDB database. GN returns the STUDENT segment which is a child segment of the CHEM1A CLASS segment in the DEDB inverted structure.

The key of the pointer segment, CHEM1A, concatenated with the key of the STUDENT segment, is returned in the key feedback area.

Because the STUDENT segment is the last segment for the CLASS segment in the database record, the second GN call returns the CLASS segment in the primary DEDB database using the next secondary index key after the CHEM1A segment in the secondary index database, CLASINDX.

The key of the next pointer segment after CHEM1A (the next sequential key after the secondary index key CHEM1A) in the Fast Path secondary index database, CLASSXDB, is returned in the key feedback area.

Example 9 of accessing a primary DEDB database that uses a Fast Path secondary index

DL/I call to insert an INSTRUCT segment on a primary DEDB database through its secondary index for the CLASS segment with a secondary index key of CHEM1A.

PCB4NDX is the PCB with the PROCSEQD= parameter defined to use the Fast Path secondary index database, CLASSXDB. The CLASS segment is the target segment and it is a not root segment. The source segment is the same as the target segment.

PCB4INDX
ISRT CLASS(CLASINDX = CHEM1A)
     INSTRUCT I23456 JOHN SMITH 

The ISRT call inserts an INSTRUCT segment with the key of I23456 under the CLASS segment with a secondary index key of CHEM1A

The key of the pointer segment, CHEM1A, concatenated with the key of the INSTRUCT segment, I23456, is returned in the key feedback area.