Khóa học miễn phí IMS DB – Data Retrieval nhận dự án làm có lương

IMS DB – Data Retrieval



The various data retrieval methods used in IMS DL/I calls are as follows −

  • GU Call
  • GN Call
  • Using Command Codes
  • Multiple Processing

Let us consider the following IMS database structure to understand the data retrieval function calls −

IMS DATABASE1

GU Call

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

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

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.

Status Codes

The following table shows the relevant status codes after a GU 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

GN Call

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

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

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.

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.

V Command Code

Points to note −

  • V command code works similar to the U command code, but it restricts the search of a segment at a particular level and all levels above the hierarchy.

  • V command code is ignored when used with a qualified SSA.

Q Command Code

Points to note −

  • Q command code is used to enqueue or reserve a segment for exclusive use of your application program.

  • Q command code is used in an interactive environment where another program might make a change to a segment.

Multiple Processing

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

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

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.

Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc