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

Reading one database record


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

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Aug 31, 2005 2:18 pm
Reply with quote

Hi all,

Can any body can tell me how to read only one database record in set of n database records. i want to terminate my program after reading one(may be 1st one or in the middle) database record. how can i do that

Thnaks&Regards,
pradeep
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Wed Aug 31, 2005 3:41 pm
Reply with quote

The following will fetch first row only.

Code:
FETCH FIRST ROW ONLY
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Thu Sep 01, 2005 9:54 am
Reply with quote

Hi radhakrishnan,

I am asking in IMS DB not in DB2, i think you r missunderstand

regards,
pradeep
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Thu Sep 01, 2005 10:31 am
Reply with quote

oh ya.misunderstood the topic section.
sorry for the inconvenience caused.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Thu Sep 01, 2005 4:00 pm
Reply with quote

Hi Pradeep,

May be it is not so simple, what I m thinking.
But dont we set a Counter after every CALL. If the Call is fine, you get the record. Checking the counter value you can STOP RUN any time.

Please give your thoughts....

Regards,

Priyesh.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Thu Sep 01, 2005 4:41 pm
Reply with quote

Normally in IMS,we fetch records till end of database condition.Putting it a loop and fetch all the records till end of condition.To Fetch one record,set End of database condition after the first record is fetched.
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Fri Sep 02, 2005 11:15 am
Reply with quote

Hi radhakrishnan,

Thanks for reply, what is my poing is we can put the EOF database(GB) condition but how can we know that the call was fetched only one record thats the thing. suppose we can check with the GA status code since it occurs when the ims control moved to next record but the prob in that is it also come when we had the twin segents in the heirarchy that is the problem, any way i will think it off and let u know ok

thanks,
pradeep
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 12:44 pm
Reply with quote

Hi Pradeep,

Quote:
what is my poing is we can put the EOF database(GB) condition but how can we know that the call was fetched only one record thats the thing


Thats why I suggested to put a counter alongwith.

It will be a great help if you can put DB structure here, so that we wont hit air.

Regards,

Priyesh.
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Fri Sep 02, 2005 5:57 pm
Reply with quote

Hi priyesh,

Can you give me the example code to how to set the counter along with the GB, I unable to think about that. actually this is interview question so i cant provide the code, sorry for that

Thanks & Regards,
pradeep
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 6:43 pm
Reply with quote

Hi Pradeep,

Please check the earlier link, I remember on counters... & see whether its of use....
http://www.ibmmainframes.com/viewtopic.php?t=4161

Else I'll try to male it more elaborate...

Regards,

Priyesh.
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Fri Sep 02, 2005 7:50 pm
Reply with quote

Hi priyesh,

I think its not the exact one, can you explain please

Thanks & Regards,
pradeep
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 8:20 pm
Reply with quote

Hi Pradeep,

I try to make in brief...

Quote:
i want to terminate my program after reading one(may be 1st one or in the middle) database record. how can i do that

This you can only do CALLing by GU. We suppose there are two level of child segment for the parent.

GU CALL on parent...If RETURN CODE = SPACES....1 record read for parent....SET ANY COUNTER here to 1....
CALL PARA CHILD 1
IF COUNTER PARENT=1 ...EXIT GU CALL PARA.

PARA CHILD 1....CALL GNP....now you perform this para up to End of DB...
& for every RETURN CODE= SPACES perform another para for level2 child...

PARA CHILD 2...CALL GNP....Up to END of DB...

This will do exactly what you are looking for.....

P.S. Dont expact a full fledged CODE.....Try & let all of us know...
Regards,

Priyesh.
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Mon Sep 05, 2005 12:18 pm
Reply with quote

Hi priyesh,

Thanks for the reply and i got the answer what i am looking for.
now i can understand clearly whar u r going to say, till now i didnt get the thhought of GU call thats why i am this much confused sorry for that and thanks for ur patience.

Thnaks,
pradeep
Back to top
View user's profile Send private message
varunraisharma

New User


Joined: 01 Sep 2005
Posts: 15
Location: Bangalore

PostPosted: Wed Sep 14, 2005 7:31 pm
Reply with quote

Please correct me if i m wrong but i think that we can make use of the command codes in the SSA in this case. For retrieving only one record we can use command code " F " in the SSA and for retrieving last record "L" can be used.
If u want to specify the path from the root segment to the last segment u can also use "D" command code.

Regards
Varun
Back to top
View user's profile Send private message
prasanth_thavva

New User


Joined: 28 Jul 2005
Posts: 86
Location: Chennai

PostPosted: Tue Oct 11, 2005 9:58 am
Reply with quote

PRADEEP,

Quote:
DECLARE FLAG FIELD.. SET IT TO NO
CHECK THE SEGMENT LEVEL ..IN PCB,,,

CHEKC IT IS IN 0 LEVEL ,,, SET THE FLAG TO TRUE...IF TRUE TERMINATE

LET ME KNOW IF ANY THING WRONG
ALLL D BEST
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 Copy only TEXT or String from a record SYNCSORT 4
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts how to complete the end of a record w... DFSORT/ICETOOL 2
No new posts Sort based on the record type DFSORT/ICETOOL 1
Search our Forums:

Back to Top