MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Read the occurences in Reverse order

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> IMS
View previous topic :: View next topic  
Author Message
sunkusiva
Beginner


Joined: 04 Apr 2006
Posts: 8
Topics: 1

PostPosted: Wed Aug 30, 2006 7:16 pm    Post subject: Read the occurences in Reverse order Reply with quote

I have a requirement where in I need to read latest 10 Records from a Child Segment. Each record is inserted to Last of this Child Segment.So latest mean, I need to read Last 10 records.
There is a Seq# (Key field) which will get incremented by each insert, But there is other pgm which deletes some Seq#s. Bottomline, I have Seq#s which are in ascending order and need not be consecutive.

Is there any way that gets me last 10 Records. Basically, I need to read the segments in reverse order.
Approach#1
I can read all the occurences from beginning, store it in to a table once counter reaches 10 flush the first one...sort the result. But the occurences for child segment are huge in number, and this approach costs me a lot to read 99% of segs which I don't want.

Approach#2
1. Get the Last Seq# by using SSA
Code:
 CHLDSEG *L

2. Get the one prior to Last by SSA (Say it fetched me 00123 in Step 1).
Code:
 CHLDSEG *L-(SEQNO   LT00123)

Repeat the Step 2 for 9 times replacing the SEQNO Value obtained in earlier Get.

Which one will be better approach?
If I use Command code 'L' does IMS internally Read all and get me last record? (If so my first approach will be better considering performance).
What is the best way? Any new approach also welcome.

Thanks
Siva.
Back to top
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Thu Aug 31, 2006 7:58 am    Post subject: Reply with quote

Execute the *L to get the last SEQNO, subtract 9, execute an GN on this new SEQNO then issue GN for the rest of the segments.
Back to top
View user's profile Send private message
sunkusiva
Beginner


Joined: 04 Apr 2006
Posts: 8
Topics: 1

PostPosted: Thu Aug 31, 2006 5:19 pm    Post subject: Reply with quote

Bithead,
Thank you.
Problem here is my Seq#s need not be consecutive.
Quote:
Bottomline, I have Seq#s which are in ascending order and need not be consecutive.

This avoids me to use the suggested approach.

Thanks
Siva.
Back to top
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Thu Aug 31, 2006 6:17 pm    Post subject: Reply with quote

Then you will need to start at the first occurrance then read sequentially to the end, saving the last 10. If you use the LT (less than), you will get any occurrance that matches, which would probably be the first.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> IMS All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group