Ims Db 简明教程
IMS DB - Data Retrieval
IMS DL/I 调用中使用的各种数据检索方法如下 −
The various data retrieval methods used in IMS DL/I calls are as follows −
-
GU Call
-
GN Call
-
Using Command Codes
-
Multiple Processing
让我们考虑以下 IMS 数据库结构,以了解数据检索函数调用 −
Let us consider the following IMS database structure to understand the data retrieval function calls −
GU Call
GU 调用的基本原理如下 −
The fundamentals of GU call are as follows −
-
GU call is known as Get Unique call. It is used for random processing.
-
If an application does not update the database regularly or if the number of database updates is less, then we use random processing.
-
GU call is used to place the pointer at a particular position for further sequential retrieval.
-
GU calls are independent of the pointer position established by the previous calls.
-
GU call processing is based on the unique key fields supplied in the call statement.
-
If we supply a key field that is not unique, then DL/I returns the first segment occurrence of the key field.
CALL 'CBLTDLI' USING DLI-GU
PCB-NAME
IO-AREA
LIBRARY-SSA
BOOKS-SSA
ENGINEERING-SSA
IT-SSA
上面的示例显示,我们通过提供一组完整的限定 SSA 来发出 GU 调用。它包括了从根级别到我们要检索的分段出现的全部键字段。
The above example shows we issue a GU call by providing a complete set of qualified SSAs. It includes all the key fields starting from the root level to the segment occurrence that we want to retrieve.
GU Call Considerations
如果我们没有在调用中提供一组完整的限定 SSA,那么 DL/I 将按以下方式工作:
If we do not provide the complete set of qualified SSAs in the call, then DL/I works in the following way −
-
When we use an unqualified SSA in a GU call, DL/I accesses the first segment occurrence in the database that meets the criteria you specify.
-
When we issue a GU call without any SSAs, DL/I returns the first occurrence of the root segment in the database.
-
If some SSAs at intermediate levels are not mentioned in the call, then DL/I uses either the established position or the default value of an unqualified SSA for the segment.
GN Call
GN调用的基本原理如下:
The fundamentals of GN call are as follows −
-
GN call is known as Get Next call. It is used for basic sequential processing.
-
The initial position of the pointer in the database is before the root segment of the first database record.
-
The database pointer position is before the next segment occurrence in the sequence, after a successful GN call.
-
The GN call starts through the database from the position established by the previous call.
-
If a GN call is unqualified, it returns the next segment occurrence in the database regardless of its type, in hierarchical sequence.
-
If a GN call includes SSAs, then DL/I retrieves only segments that meet the requirements of all specified SSAs.
CALL 'CBLTDLI' USING DLI-GN
PCB-NAME
IO-AREA
BOOKS-SSA
上面的示例显示我们发出一个 GN 调用,提供开始读取记录的顺序位置。它获取 BOOKS 段的第一个出现。
The above example shows we issue a GN call providing the starting position to read the records sequentially. It fetches the first occurrence of the BOOKS segment.
Status Codes
下表显示 GN 调用后的相关状态码 −
The following table shows the relevant status codes after a GN call −
S.No |
Status Code & Description |
1 |
Spaces Successful call |
2 |
GE DL/I could not find a segment that met the criteria specified in the call. |
3 |
GA An unqualified GN call moves up one level in the database hierarchy to fetch the segment. |
4 |
GB End of database is reached and segment not found. |
GK An unqualified GN call tries to fetch a segment of a particular type other than the one just retrieved but stays in the same hierarchical level. |
Command Codes
命令码与调用一起用于获取段出现。下面将讨论与调用一起使用的各种命令码。
Command codes are used with calls to fetch a segment occurrence. The various command codes used with calls are discussed below.
F Command Code
重点注意事项:
Points to note −
-
When an F command code is specified in a call, the call processes the first occurrence of the segment.
-
F command codes can be used when we want to process sequentially and it can be used with GN calls and GNP calls.
-
If we specify an F command code with a GU call, it does not have any significance, as GU calls fetch the first segment occurrence by default.
L Command Code
重点注意事项:
Points to note −
-
When an L command code is specified in a call, the call processes the last occurrence of the segment.
-
L command codes can be used when we want to process sequentially and it can be used with GN calls and GNP calls.
D Command Code
重点注意事项:
Points to note −
-
D command code is used to fetch more than one segment occurrences using just a single call.
-
Normally DL/I operates on the lowest level segment specified in an SSA, but in many cases, we want data from other levels as well. In those cases, we can use the D command code.
-
D command code makes easy retrieval of the entire path of segments.
C Command Code
重点注意事项:
Points to note −
-
C command code is used to concatenate keys.
-
Using relational operators is a bit complex, as we need to specify a field name, a relational operator, and a search value. Instead, we can use a C command code to provide a concatenated key.
以下示例演示了 C 命令码的使用 −
The following example shows the use of C command code −
01 LOCATION-SSA.
05 FILLER PIC X(11) VALUE ‘INLOCSEG*C(‘.
05 LIBRARY-SSA PIC X(5).
05 BOOKS-SSA PIC X(4).
05 ENGINEERING-SSA PIC X(6).
05 IT-SSA PIC X(3)
05 FILLER PIC X VALUE ‘)’.
CALL 'CBLTDLI' USING DLI-GU
PCB-NAME
IO-AREA
LOCATION-SSA
P Command Code
重点注意事项:
Points to note −
-
When we issue a GU or GN call, the DL/I establishes its parentage at the lowest level segment that is retrieved.
-
If we include a P command code, then the DL/I establishes its parentage at a higher level segment in the hierarchical path.
U Command Code
重点注意事项:
Points to note −
-
When a U command code is specified in an unqualified SSA in a GN call, the DL/I restricts the search for the segment.
-
U command code is ignored if it is used with a qualified SSA.
Multiple Processing
一个程序可以在 IMS 数据库中具有多个位置,这被称为多重处理。多重处理可以通过两种方式完成:
A program can have multiple positions in the IMS database which is known as multiple processing. Multiple processing can be done in two ways −
-
Multiple PCBs
-
Multiple Positioning
Multiple PCBs
可以为单个数据库定义多个 PCB。如果存在多个 PCB,那么应用程序可以对其有不同的视图。此实现多重处理的方法由于额外 PCB 带来的开销而效率低下。
Multiple PCBs can be defined for a single database. If there are multiple PCBs, then an application program can have different views of it. This method for implementing multiple processing is inefficient because of the overheads imposed by the extra PCBs.
Multiple Positioning
一个程序可以使用单个 PCB 在数据库中维护多个位置。这是通过为每个分层路径维护一个不同的位置来实现的。多重定位用于同时以顺序方式访问两个或更多类型的段。
A program can maintain multiple positions in a database using a single PCB. This is achieved by maintaining a distinct position for each hierarchical path. Multiple positioning is used to access segments of two or more types sequentially at the same time.