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:
- Suppose your program must retrieve segments from different hierarchic paths alternately:
for example, in the following figure, it might retrieve B11, then C11, then B12, then C12, and so
on. If your program uses multiple positioning, IMS
maintains positions in both hierarchic paths. Then the program is not required to issue
GU
calls to reset position each time it needs to retrieve a segment from a different path. - Suppose your program must retrieve segments from different database records alternately:
for example, it might retrieve a B segment under A1, and then a B segment under another A root
segment. If your program uses multiple PCBs, IMS
maintains positions in both database records. Then the program does not have to issue
GU
calls to reset position each time it needs to access a different database record.

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.
GU Abbbbbbb(AKEYbbbb=bA1)
Bbbbbbbb(BKEYYbbbb=bB11)
Cbbbbbbb(CKEYYbbbb=bC111)
GN Ebbbbbbb(EKEYYbbbb=bE11)

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.

The examples that follow compare the results of single and multiple positioning using the hierarchy in the following figure.
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.