Defining DBD statements for logically related HALDB databases

Define the DBD statements for each logically related HALDB database.

The statements that you need to modify are:

  • The DBD statement
  • The SEGM statement
  • The LCHILD statement
  • The XDFLD statement
  • The FIELD statement

HALDB databases do not use the DATASET statement.

Changing pointer options for logical relationships

Logically related databases might require changes to pointers in addition to the changes that are required for databases that do not have logical relationships.

HALDB does not use symbolic pointers. You must change any logical relationship that has been implemented with symbolic pointing. You can do this by adding the LPARNT keyword to the PTR parameter on the SEGM statement for the logical child.

Although symbolic pointing is not used, the concatenated key of the logical parent is stored in the logical child, regardless of the keywords that you use in the PARENT parameter. That is, PHYSICAL or P is used, even when you specify VIRTUAL or V. To avoid the warning message that is issued when VIRTUAL or V is specified, you should specify the PHYSICAL or P keyword.

Recognizing virtual pairing

You can determine if you have virtual pairing by examining your DBDs. If your HDAM or HIDAM database contains a SEGM statement with a SOURCE parameter, this segment is a virtual logical child. The first subparameter of the SOURCE parameter identifies the real logical child. The third subparameter identifies the database in which the real logical child resides. In the following example of a HIDAM DBD with a logical relationship, the NAMESKIL segment in the DBD contains a SOURCE parameter. It is a virtual logical child.

The source parameter references the SKILNAME segment in the SKILLINV database in Figure 2, in which SKILNAME is a real logical child.

Figure 1. Example: HIDAM DBD with a logical relationship
         DBD    NAME=PAYROLDB,ACCESS=HIDAM                               
         DATASET DD1=PAYHIDAM,BLOCK=1648,SCAN=3                           
         SEGM   NAME=NAMEMAST,PTR=TWINBWD,RULES=(VVV),                 X
               BYTES=150                                                 
         LCHILD NAME=(INDEX,INDEXDB),PTR=INDX                            
         LCHILD NAME=(SKILNAME,SKILLINV),PAIR=NAMESKIL,PTR=DBLE          
         FIELD  NAME=(EMPLOYEE,SEQ,U),BYTES=60,START=1,TYPE=C            
         SEGM   NAME=NAMESKIL,PARENT=NAMEMAST,PTR=PAIRED,              X 
               SOURCE=((SKILNAME,DATA,SKILLINV))                         
         FIELD  NAME=(TYPE,SEQ,U),BYTES=21,START=1,TYPE=C                
         DBDGEN
                                                                  
         FINISH 
                                                                 
         END 
Figure 2. Example: HDAM DBD with a logical relationship
         DBD    NAME=SKILLINV,ACCESS=HDAM,RMNAME=(DFSHDC40,1,500,824)    
         DATASET DD1=SKILHDAM,BLOCK=1648,SCAN=0                           
         SEGM  NAME=SKILMAST,BYTES=31,PTR=TWINBWD                         
         FIELD NAME=(TYPE,SEQ,U),BYTES=21,START=1,TYPE=C                  
         SEGM  NAME=SKILNAME,                                          X  
               PARENT=((SKILMAST,DBLE),(NAMEMAST,P,PAYROLDB)),         X  
               BYTES=80,PTR=(LPARNT,LTWINBWD,TWIN)                        
         FIELD NAME=(EMPLOYEE,SEQ,U),START=1,BYTES=60,TYPE=C              
         DBDGEN                                                           
         FINISH                                                           
         END 

Converting virtual pairing to physical pairing

If your existing logically related databases use virtual pairing, you need to modify the DBD statements to convert them to HALDB.

To convert a virtually paired logical relationship to physical pairing, complete the following steps:

  1. Add an LCHILD statement under the parent of the segment that was the real logical child. In Figure 1, this is the SKILMAST segment. Make the following changes to this LCHILD statement:
    • In the new LCHILD statement, include a NAME parameter that specifies the segment that had the SOURCE parameter. In Figure 1, this is NAMESKIL.
    • In the PAIR parameter, specify the same segment that was specified in the SOURCE parameter. This segment was the real logical child. In Figure 1, this is SKILNAME.
  2. Find the LCHILD statement that references the segment that was the real logical child. In Figure 1, this is the LCHILD statement in the PAYROLDB database that includes NAME=(SKILNAME,SKILLINV). Make the following changes to this LCHILD statement:
    • Delete the PTR parameter.
    • If there is a RULES parameter, delete it.
  3. Find the SEGM statement that defined the virtual logical child. In Figure 1, this is the NAMESKIL segment. Make the following changes to the SEGM statement:
    • Add a BYTES parameter. The lengths of the fixed intersection data in the paired logical children must be the same. The BYTES parameter includes both the fixed intersection data and the logical parent's concatenated key (LPCK). You can calculate the BYTES value for this segment by taking the BYTES value from the paired logical child's SEGM statement, adding the LPCK size for this segment, and subtracting the LPCK size for the paired logical child. In Figure 1, the paired logical child for the NAMESKIL segment is the SKILNAME segment. Its size is 80 bytes. The LPCK for the NAMESKIL segment is the TYPE field in the SKILMAST segment. Its size is 21 bytes. The LPCK for the SKILNAME segment is the EMPLOYEE field in the NAMEMAST segment. Its size is 60 bytes. The BYTES parameter for the NAMESKIL segment should be 41, which is 80 + 21 - 60.
    • Delete the SOURCE parameter.
    • Change the PARENT parameter so that it also references its logical parent. In Figure 1, this is the SKILMAST segment. The PARENT parameter should also include the PHYSICAL or P keyword.
    • Change the PTR parameter specifications. Include PAIRED. Include TWIN, T, TWINBWD, TB, NOTWIN, or NT. Do not use NOTWIN or NT unless you will have a maximum of only one instance of this segment type under a parent.
  4. Find the SEGM statement for the segment that was the real logical child. In Figure 1, this is the SKILNAME segment. Make the following changes to this SEGM statement:
    • Change the PARENT parameter so that neither SNGL nor DBLE is specified. If VIRTUAL or V was specified, change this to PHYSICAL or P.
    • Change the PTR parameter specifications. Delete LTWIN, LT, LTWINBWD, or LTB keywords if they exist. Specify both the LPARNT and PAIRED keywords.

Figure 3 and Figure 4 show the DBDs from Figure 1 and Figure 2 after they have been converted to HALDB databases with physical pairing. In addition to the changes that were made for logical relationships, other changes for the conversion to HALDB have been made. These are changes in the ACCESS parameter on the DBD statements and deletion of the DATASET statements.

Figure 3. Example: PHIDAM DBD with a logical relationship
         DBD   NAME=PAYROLDB,ACCESS=PHIDAM                              
         SEGM  NAME=NAMEMAST,PTR=TWINBWD,RULES=(VVV),                  X
               BYTES=150                                                
         LCHILD NAME=(SKILNAME,SKILLINV),PAIR=NAMESKIL                  
         FIELD NAME=(EMPLOYEE,SEQ,U),BYTES=60,START=1,TYPE=C            
         SEGM  NAME=NAMESKIL,                                          X
               PARENT=((NAMEMAST),(SKILMAST,P,SKILLINV)),              X
               BYTES=41,PTR=(TWIN,PAIRED)                               
         FIELD NAME=(TYPE,SEQ,U),BYTES=21,START=1,TYPE=C                
         DBDGEN                                                         
         FINISH                                                         
         END 
Figure 4. Example: PHDAM DBD with a logical relationship
         DBD   NAME=SKILLINV,ACCESS=PHDAM,RMNAME=(DFSHDC40,1,500,824)   
         SEGM  NAME=SKILMAST,BYTES=31,PTR=TWINBWD                       
         FIELD NAME=(TYPE,SEQ,U),BYTES=21,START=1,TYPE=C                
         LCHILD NAME=(NAMESKIL,PAYROLDB),PAIR=SKILNAME                  
         SEGM  NAME=SKILNAME,                                          X
               PARENT=((SKILMAST),(NAMEMAST,P,PAYROLDB)),              X
               BYTES=80,PTR=(TWIN,PAIRED)                               
         FIELD NAME=(EMPLOYEE,SEQ,U),START=1,BYTES=60,TYPE=C            
         DBDGEN                                                         
         FINISH                                                         
         END