DELETION IN ISAM FILE
Posted 26 January 2006 - 09:25 PM
i am trying to delete records in key file , but not able to .
it is a .PRO file.
defalut logic : sel-only(first key field) this file has two key fields
file is in 'D' mode.
i didn't inderstand why the records are not getting deleted.
Pl. guide me here
Posted 27 January 2006 - 04:36 PM
this made me to think that records are not getting deleetd.
But the problem is with records are not written into it.
How to read an isam file sequentially. i have assigned all key fields values "" and trying to read the file.
i am able to display UMsg IN BEFORE READ , but not able to display in after read no err and after read err.
control is going to exit logic directly after before read in the group. "
what can be the problem
Posted 27 January 2006 - 09:11 PM
one big Q for me is that
why i am not able to read pro files with partial key ( ie first field of two key fields- sel-only)
as i failed to do this , now i have removed sel-only from default logic.
can you guys pl. let me know, in what scnerios we can't do sel-only for pro file.
Posted 28 January 2006 - 12:05 AM
Here's a quick guide then. appologies if any of it is stating the obvious, just trying to (quickly) cover the majority of cases for SEL-ONLY and SEL-PARTIAL :-
SEL-ONLY is used to select a specific record or sub-set of records.
For example. if we have a file with two keys and the following 4 records:
1) a, aa
2) a, ab
3) a, ba
4) b, a
If we set key1 to 'a' and do a SEL-ONLY(key1) then it will return records 1 to 3.
If we set key1 to 'b' and do the same, only record 4 will be returned.
The sel-only on the primary key in this case is returning a subset of data where the records match the 1st key value that we specified.
Now if we set key1 to 'a' and key2 to 'aa' and do a SEL-ONLY(key2) then only record 1 is returned. This is because in this case it is the only record that matches both keys.
If I understand correctly then in your example, you would have set key1 to '' and key2 to '' and performed a SEL-ONLY(key1). In this case no records would be returned as there are no records that match a blank 1st key. The second key is not even considered as it is not in the SEL-ONLY.
For partial reads, you can use SEL-PARTIAL instead of SEL-ONLY. SEL-PARTIAL will partially match the key that you give it and explicitly match any keys that are higher than it on the record.
For example, if we set key1 to 'a' and key2 to 'a' and do a SEL-PARTIAL(key2) we will get records 1 and 2. PROIV will select all records that explicitly match key1 ('a') and partially match key2 ('aa' and 'ab' match the partial string 'a').
If we just set key1 to 'a' and SEL-PARTIAL(key1) then this time we will get records 1,2 and 3.
If we set key1 to 'a' and key2 to '' and SEL-PARTIAL(key2) we will get the same result - records 1,2 and 3 explicitly match key1='a' and partially match key2 of ''.
If we set both keys to '' and do a SEL-PARTIAL on key2 then this time we don't get any data. Maybe that's not what you guessed. The reason is that PROIV will select records with the first key matching '' and a partial second key of ''. There aren't any with a '' first key of course! Doing a SEL-PARTIAL on key2 in this case is actually just the same as doing a SEL-ONLY(key1).
If we set key1 to '' and requested SEL-PARTIAL(key1) though, well we'd get ALL records. This is because they all partially match an empty 1st key. This btw is the default selection behaviour of a cycle, and is the same as if there were no logic at all.
Anyway, that was a pretty quick example so hope it makes sense! (& I've not made any typos!)
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users