View previous topic :: View next topic
|
Author |
Message |
srrao_kilari
New User
Joined: 28 Nov 2005 Posts: 12 Location: New Delhi
|
|
|
|
I have records like below in VASM KSDS file.
1 ....
2 ....
3 .....
4 ....
6 .....
7 .....
9 .....
.
I am reading records in sequence and if it passes one condition(not required here) it will write a new record as a next record. For example it the 4th record passes the conditon it will write new record i.e. 5th. After writing the record it has a READ stmnt. But what actually happening in my results is the values in the read stmnt are of 7th. Here I am expecting values of 6th record. Can anybody please explain the reason. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
This is what I think is happening.
Several years ago, I had a similar experience and this is the way it was explained to me.
You have the file open in IO mode. You start to read the file sequentially; there is only one pointer to the current record. When you read the first record the pointer is on entry 1 key 1, when you read the next record, the current record pointer is incremented by 1 and you read the next entry 2 key 2, and so on? After you read entry 4 key 4, the current record pointer is set at entry 4. You now write key 5, and since there is only 1 current record pointer it is now set at entry 5. (this is where the problems come in) The index you have in storage has not been updated with the new record key at this time, so when you read next, it takes the current record pointer (5), increments by 1 to 6 and reads the 6th entry from the index, or key 7. Whenever you do a write, you need to re-position yourself in the file.
I probably stated this badly, Is it clear enough?
Dave |
|
Back to top |
|
|
srrao_kilari
New User
Joined: 28 Nov 2005 Posts: 12 Location: New Delhi
|
|
|
|
It looks appropriate answer. Thank u very much. |
|
Back to top |
|
|
sharda
New User
Joined: 13 Sep 2006 Posts: 7
|
|
|
|
Hi ,
I am not getting ur explaination . Why u r telling that problem comes only at 6 th record and not on 3 rd record ? |
|
Back to top |
|
|
srrao_kilari
New User
Joined: 28 Nov 2005 Posts: 12 Location: New Delhi
|
|
|
|
I gave an example where 4th record is satisfying the condition and should write 5th record not 3rd or any. |
|
Back to top |
|
|
|