IMS DB Insert Call
Segments are added to an IMS database by using the insert call, ISRT.
IMS inserts the segment at the proper position in the database based on the value in the key field of the io-area.
While inserting a child or dependent or segment, the key of the parent may or may not be provided.
If the parent is not qualified, the segment will be inserted at the current database position as a child of the last parent processed in the previous call.
If the parent is qualified, the segment will be inserted as a child of the specified parent regardless of the database current position.
The type of segment to be inserted must always be specified with ISRT call.
IMS takes the required information from the io-area for insertion.
IMS will use the information in the io-area to create the new segment on the database and will use the segment length from the DBD.
The Insert (ISRT) call is used to load database to add one or more segments to the database.
Application program can use ISRT to add a record to the end of a GSAM database.
CALL ‘CBLTDLI’ USING ISRT db pcb/aib i/o area ssa
Lets discuss about individual parameters.
- Database Program Control Block
- Specifies the DB PCB for the GN call.
- DB PCB will act as an input and output parameter.
- Known as Application Interface Block.
- Specifies the AIB for the call.
- AIB parameter is an input and output parameter.
- If AIB using in the GN call, all the below fields must be initialized in the AIB
AIBID, AIBLEN, AIBRSNM1, AIBOALEN
- Known as Input-Output Area.
- Specifies the I/O area in GN Call.
- I/O Area parameter is an output parameter.
- If Insert calls completed successfully, IMS returns the requested segment in I/O area.
- If any path calls issued from the application program, the I/O area must be long enough to hold the longest path of concatenated segments.
- I/O area always contains left-justified segment data.
- The I/O area points to the first byte of this area.
- Known as Segment Search Arguments.
- Specifies to be used in the call.
- SSA parameter is an input parameter.
- The SSA supplies in the call to data areas in the application program where the SSA has been defined for the call.
- Up to 15 SSAs can be used in the parameter.
- SSA parameter is optional for the GN call.
Application program uses the ISRT call to initially load a database.
And also used to add information to an existing segment.
The processing option will be used to determine the type of the call from above two in the PCB.
ISRT can add new occurrences of an existing segment type to a HIDAM, PHIDAM, HISAM, HDAM, PHDAM, DEDB, or MSDB database.
Before application program issue the ISRT call, it should build the new segment in the I/O area.
The new segment fields must be in the same order and of the same length as defined for the segment.
If adding a root segment occurrence, IMS places it in the correct sequence in the database by using the key supplied in the I/O area.
If the segment inserting is not a root, application program can insert the child segment by issuing an ISRT call with an unqualified SSA.
Unqualified SSA needs to be used when application program inserting a root.
At least one SSA is required in an ISRT call always
Qualified and unqualified SSAs can mix up during the ISRT call, but the last SSA must be unqualified.
If the segment type inserting has a unique key field, the place where IMS adds the new segment occurrence can be determined by the value of its key field.
If the segment does not have a key field or key is not unique, application program can control where the new segment occurrence is added by specifying either the FIRST, LAST, or HERE insert rule.
The rules on the RULES parameter are like below:
In the FIRST rule, IMS inserts the new segment occurrence before the first existing occurrence of this segment type.
If the inserting segment has a non unique key, IMS inserts the new occurrence before all existing occurrences of the same key field segments.
In the LAST rule, IMS inserts the new occurrence after the last existing occurrence of the segment type.
If the segment occurrence has a non unique key, IMS inserts the new occurrence after all existing occurrences of the same key field segments.
In the HERE rule, IMS assumes application program can have a position on the segment type from a previous IMS call.
IMS places the new occurrence before the segment occurrence which is immediately before current position.
Insert path call:
An insert path call, is used to insert an entire path of segments, or selected segments in a path, in one database call.
DL/I expect the segment in the io-area to be one after the other, from left to right.
The segments must be in the order of the path and each segment must be exactly as long as defined in the DBD.
The entire path will be inserted.
To insert a path of segments, code a D in the command code of the SSA of the first segment to be inserted.IMSDB Get Hold Unique(GHU) IMSDB Replace(REPL)