IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting more than one segment at a time


IBM Mainframe Forums -> IMS DB/DC
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Thu Oct 01, 2009 6:57 pm
Reply with quote

Hi All,
I have a requirement to insert three segments. A root segment and two of its lower level segments. I wanted to know if this was possible using a single INSRT call by giving command code as D.

For Example:
|--Level 1 - Seg A
|-------| - Level 2 - Seg B
|-------|----| - Level 3 - Seg C

In the above Example, lets say that I have to insert All the three at a time, Can I do it? Please advise.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Oct 01, 2009 10:54 pm
Reply with quote

Yes - you will do a path insert.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Oct 01, 2009 11:26 pm
Reply with quote

Question - why would you want to do it this way? Does each parent segment have only 1 child segment?
Back to top
View user's profile Send private message
Tapas M Patel

New User


Joined: 15 Dec 2008
Posts: 2
Location: Chennai, India

PostPosted: Tue Oct 06, 2009 3:27 pm
Reply with quote

Hi Sandy,
Thanks for the reply. I am referring to a scenario where in I have to enter one complete occurence of database.

For Example: I have Employee Database wherein, EMPID - Root segment, EMPPER - Employee personal details ( A level 1 segment), EMPBUS - Employee Business Details( A level 1 segment) and then Under EMPBUS, I have two other segments -( EMPCURR - Current details) and (EMPPREV - Previous details)

|----EMPID -> Root segment
|------|--EMPPER ->Level1
|------|--EMPBUS -> Level2
|------|-----|--EMPCURR -> Level3
|------|-----|--EMPPREV -> Level3

So here I need to insert the details of Employee with EMPID - XYZ into already existing database. I have to insert all the five segments. Please let me know if the explanation is not clear.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Tue Oct 06, 2009 4:32 pm
Reply with quote

Most IMS databases are designed to reduce redundant data. When designing a database, it is usually a 1 to many in the relationship between a parent and it's child segments. So, for each parent you have the possibility of many child segments. If you are inserting a parent and you need to insert MANY child segments at the same time, you cannot do that with 1 path call. You would need to set up a loop.
Back to top
View user's profile Send private message
Tapas M Patel

New User


Joined: 15 Dec 2008
Posts: 2
Location: Chennai, India

PostPosted: Tue Oct 06, 2009 5:32 pm
Reply with quote

Hi Sandy,
There are two queries

a) for the reply "So, for each parent you have the possibility of many child segments. If you are inserting a parent and you need to insert MANY child segments at the same time, you cannot do that with 1 path call." Here when you say MANY child segment are you referring to a scenario where I have many same child segments or is it in general and also applicable for MANY different child segments for same parent. Please Clarify.

b) For the reply "You would need to set up a loop." - In this scenario, when I first insert the root segment how will I point to that to insert the child segments under it. I mean after CALL-INSERT of EMPID for employee xyz, how will I insert the business details and personal details? Can I use GET-UNIQUE call and point to that root( EMPID = XYZ). Please clarify

Please let me know in case my explanation of the query is not clear.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Tue Oct 06, 2009 5:48 pm
Reply with quote

Quote:
Here when you say MANY child segment are you referring to a scenario where I have many same child segments or is it in general and also applicable for MANY different child segments for same parent. Please Clarify.


Remember that IMS is positional. If you have a root segment and want to insert any kind of child segment, you will need to use a qualified SSA for that root and an unqualified SSA for the specific child. If you are qualifiying the root SSA and get a "GE" on your insert, think about why.

Quote:
I mean after CALL-INSERT of EMPID for employee xyz, how will I insert the business details and personal details? Can I use GET-UNIQUE call and point to that root( EMPID = XYZ). Please clarify


How you design and code is dependent on the scenario. Where is the data coming from? Is it an input file - is it online?
Back to top
View user's profile Send private message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Wed Oct 07, 2009 7:21 pm
Reply with quote

Hi Sandy,
The data is coming from the input file and I need to insert a new employee with all the details. When I say all the details, I mean that the EMPID(i.e the root segment) and other child segments will also have to be updated. I have accomplished this task by inserting the root first in a Program A, and then by invoking a GET-UNIQUE call to that inserted ROOT and inserting the Level 1 segments in Program B. Finally inserting the Level 3 segments for the above inserted ROOT in Program C. This process is working fine for me. I wanted to know if the entire process can be done in one program. If yes then, can I point to the inserted ROOT by giving GET-UNIQUE after giving a CALL-INSERT?

And for the reply, "Remember that IMS is positional. If you have a root segment and want to insert any kind of child segment, you will need to use a qualified SSA for that root and an unqualified SSA for the specific child. If you are qualifiying the root SSA and get a "GE" on your insert, think about why. " - I am confused if this was the one to what I actually asked, If yes please clarify.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Wed Oct 07, 2009 7:29 pm
Reply with quote

You can accomplish the entire process in 1 program - it will save system resources. It will also be much easier. And, most important - easier to maintain.

Can we have a look at the structure of the input file? Overall, you will insert the root segment and then insert all pertaining child segments while you are positioned on that root. You will not need to issue a get unique - you will be qualifying - by qualified SSA - down to the segment you are inserting - B or C.

We just need to see the structure of your input file.
Back to top
View user's profile Send private message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Fri Oct 09, 2009 6:35 pm
Reply with quote

Hi Sandy,
Please find my input file layout below.

01 EMP-INFO-REC.
05 EMP-ID PIC 9(06).
05 EMP-FIRST-NAME PIC X(20).
05 EMP-LAST-NAME PIC X(20).
05 EMP-DOB PIC 9(06).
05 EMP-PHONE-NO PIC 9(10).
05 EMP-DESG PIC X(05).
05 EMP-DOMAIN PIC X(10).
05 EMP-CURR-ROLE PIC X(05).
05 EMP-PREV-ROLE PIC X(05).

There are five records in the input file as per the above layout. The fields should go into various segments of the database based on below logic.

EMP-ID - In EMPID segment (Key)

In EMPPER segment:

05 EMP-FIRST-NAME PIC X(20).
05 EMP-LAST-NAME PIC X(20).
05 EMP-DOB PIC 9(06).
05 EMP-PHONE-NO PIC 9(10).

In EMPBUS segment:

05 EMP-DESG PIC X(05).
05 EMP-DOMAIN PIC X(10).

In EMPCURR segment:

05 EMP-CURR-ROLE PIC X(05).

In EMPPREV segment:

05 EMP-PREV-ROLE PIC X(05).

Please let me know how can I insert all these values at one go.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Oct 09, 2009 7:47 pm
Reply with quote

Are these input file fields all on 1 record - it appears that they are?
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Oct 09, 2009 7:57 pm
Reply with quote

Also.....

|----EMPID -> Root segment - level 1
|------|--EMPPER ->Level1 -------root segment
|------|--EMPBUS -> Level2 -----child of EMPPER
|------|-----|--EMPCURR -> Level3 -----child of EMPBUS
|------|-----|--EMPPREV -> Level3 ------child of EMPBUS

Level 1 indicates ROOT segment- you do not have a root segment with just a key - right? Also, why are the other segments children? What are the keys for these segments?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> IMS DB/DC

 


Similar Topics
Topic Forum Replies
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
Search our Forums:

Back to Top