View previous topic :: View next topic
|
Author |
Message |
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
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 |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
The following will fetch first row only.
Code: |
FETCH FIRST ROW ONLY |
|
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
Hi radhakrishnan,
I am asking in IMS DB not in DB2, i think you r missunderstand
regards,
pradeep |
|
Back to top |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
oh ya.misunderstood the topic section.
sorry for the inconvenience caused. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
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 |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
Hi priyesh,
I think its not the exact one, can you explain please
Thanks & Regards,
pradeep |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
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 |
|
|
varunraisharma
New User
Joined: 01 Sep 2005 Posts: 15 Location: Bangalore
|
|
|
|
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 |
|
|
prasanth_thavva
New User
Joined: 28 Jul 2005 Posts: 86 Location: Chennai
|
|
|
|
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 |
|
|
|