Multiple processing

The order in which an application program accesses segments in a hierarchy depends on the purpose of the application program. Some programs access segments directly, others sequentially. Some application programs require that the program process segments in different hierarchic paths, or in different database records, in parallel.

If your program must process segments from different hierarchic paths or from different database records in parallel, using multiple positioning or multiple PCBs can simplify the program's processing. For example:

Figure 1. Multiple processing
begin figure description - This figure is described in the surrounding text. end figure description.

Multiple positioning

When you define the PSB for your application program, you have a choice about the kind of positioning you want to use: single or multiple. All of the examples used so far, and the explanations about current position, have used single positioning.

Specify the kind of position you want to use for each PCB on the PCB statement when you define the PSB. The POS operand for a DEDB is disregarded. DEDBs support multiple positioning only.

Single positioning
IMS maintains position in one hierarchic path for the hierarchy that is defined by that PCB. When you retrieve a segment, IMS clears position for all dependents and all segments on the same level.
Multiple positioning
IMS maintains position in each hierarchic path in the database record that is being accessed. When you retrieve a segment, IMS clears position for all dependents but keeps position for segments at the same level. You can process different segment types under the same parent in parallel.
For example, suppose you issue these two calls using the hierarchy shown in the following figure:
GU    Abbbbbbb(AKEYbbbb=bA1)
      Bbbbbbbb(BKEYYbbbb=bB11)
      Cbbbbbbb(CKEYYbbbb=bC111) 
GN    Ebbbbbbb(EKEYYbbbb=bE11)
Figure 2. Multiple positioning hierarchy
Hierarchical relationship between segment types. Segment A is parent of segments B and E. Segment B is parent of segments C and D. Segment E is parent of segment F

After issuing the first call with single positioning, IMS has three positions established: one on A1, one on B11, and one on C111. After issuing the second call, the positions on B11 and C111 are canceled. Then IMS establishes positions on A1 and E11.

After issuing the first call with single and multiple positioning, IMS has three positions established: one on A1, one on B11, and one on C111. However, after issuing the second call, single positioning cancels positions on B11 and C111 while multiple positioning retains positions on B11 and C111. IMS then establishes positions on segments A1 and E11 for both single and multiple positioning.

After issuing the first call with multiple positioning, IMS has three positions established (just as with single positioning): one on A1, one on B11, and one on C111. But after issuing the second call, the positions on B11 and C111 are retained. In addition to these positions, IMS establishes position on segments A1 and E11.

Figure 3. Single and multiple positioning hierarchy
begin figure description - This figure is described in the surrounding text. end figure description.

The examples that follow compare the results of single and multiple positioning using the hierarchy in the following figure.


Table 1. Results of single and multiple positioning with DL/I calls
    Sequence Result of Single Positioning Result of Multiple Positioning
Example 1    
GU (where AKEY equals A1) A1 A1
GNP B B11 B11
GNP C C11 C11
GNP B Not found B12
GNP C C12 C12
GNP B Not found B13
GNP C C13 C13
GNP B Not found Not found
GNP C Not found Not found
Example 2    
GU A (where AKEY equals A1) A1 A1
GN B B11 B11
GN C C11 C11
GN B B21 B12
GN C C21 C12
Example 3    
GU A (where AKEY equals A1) A1 A1
GN C C11 C11
GN B B21 B11
GN B B22 B12
GN C C21 C12  
Example 4    
GU A (where AKEY equals A1) A1 A1
GN B B11 B11
GN C C11 C11
GN D D111 D111
GN E E111 E111
GN B B21 B12
GN D D221 D112
GN C C under next A C12
GN E E under next A E121  
     

Multiple positioning is useful when you want to examine or compare segments in two hierarchic paths. It lets you process different segment types under the same parent in parallel. Without multiple positioning, you would have to issue GU calls to reestablish position in each path.