Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reading one database record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> IMS DB/DC
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    Post subject: Reading one database record
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: 436
Location: chennai, India

PostPosted: Wed Aug 31, 2005 3:41 pm    Post subject:
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    Post subject:
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: 436
Location: chennai, India

PostPosted: Thu Sep 01, 2005 10:31 am    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Thu Sep 01, 2005 4:00 pm    Post subject: Re: Reading one database record
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: 436
Location: chennai, India

PostPosted: Thu Sep 01, 2005 4:41 pm    Post subject:
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    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 12:44 pm    Post subject: Re: Reading one database record
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    Post subject: Re: Reading one database record
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: 1452
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 6:43 pm    Post subject: Re: Reading one database record
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    Post subject: Re: Reading one database record
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: 1452
Location: Chicago, IL

PostPosted: Fri Sep 02, 2005 8:20 pm    Post subject: Re: Reading one database record
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    Post subject: Re: Reading one database record
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    Post subject:
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    Post subject: i want to terminate my program after reading one(may be 1st
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    IBMMAINFRAMES.com Support Forums -> IMS DB/DC All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Need help in reading and validating a... ABINAYATHULASI COBOL Programming 8 Tue Apr 18, 2017 11:42 am
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us