[Info-vax] Indexed RMS file question
Hein, Nashua NH
heinvandenheuvel at gmail.com
Fri Oct 2 12:55:01 EDT 2009
On Oct 2, 12:04 pm, "J Xenu" <j_x... at hotmail.com> wrote:
> It's been a LONG time since I used indexed RMS files on VMS.
Nothing changed.
>
> I have some data that I wish to place in an RMS indexed file, that is to be
> accessed randomly using keys. The way I see it, there will be 3 or 4 keys.
> Two will be text, of fixed length, with duplicates allowed. The other one or
> two are integer, more on these later.
Sorry, we need to know NOW.
If you want RMS'es help with this then you need to store those
integers integer values in TEXT representation either with leading
zeroes, or right justified. Can do?
The reason is that RMS only allows STRING fields in segmented keys,
and you are going to want to use segmented keys.
[ actually.. you can use integers, but you need to segment them a byte
at a time in reverse order and you'll soon hit the 8 segment max
besides it looking rather ugly and unmaintainable as in "try to
explain it to the next guy" ]
> 1) Read a record that matches the first text key. Simple enough.
Indeed.
> 2) Read a record that matches both text keys. I want to read a record matching
> both the first and second keys. There may be more than one matching record,
> if so, I want to access them in order.
Always in first, second order?
Just expand the first key to include the second key, either by
sufficiently growing its size if adjacent, or by adding a segment
corresponding to the second key.
You can still use the key fro case 1) by looking up with a key size
reduced to the length of the first segment.
> 3) Using the first text key and an integer key, I want to read any record that
> matches the first key and the integer falls within the range of the third
> key.
RMS does not do ranges. But you can.
It can START greater (or equal) and LIMIT, on read nexts. (RAB$V_LIM)
The 3rd key key be FIRST field + SEGMENT for third fields.
Now you can do READ KEY #2 ( 0 beased :-) >= "Alpha 0042"
> Best described with an example: Assume the file has the content as follows:
> (I'll leave out the second key since it's not relevant now)
>
> Key 1 Key 3 Data
>
> Alpha 1-18 data
I don't get it.
Does the above represent 18 records or 1 record or 2 records?
18: One field, one record for each value
1: One record with 2 distinct columns one for the start value, one for
the end value.
2: One record to mark the beginning, one more to mark the then of a
range.Yuck.
> Assume I do a read with Key 1 = "Beta" and Key 3 = 42. I want the read to
> return the record with data = "This is the data I want" since key 1 matches
> and Key 3 falls within the range 33-50. How do I define the keys, especially
> Key 3 without creating a duplicate record for each possible key3 value?
Ah, I think that answers my question. It sounds like you really want a
range, not 18 records the above example.
I think the solution will be the single record with begin and end
range columns and to hard-code a loop over those.
READ with key >= "Alpha"
LOOP:
NOT_FOUND - If FIRST fields not equal to "Alpha"
FOUND - if NUMBER > begin and < END
TRY AGAIN If number > END
READ with key >= "Alpha" + <last-end>
goto loop.
Good luck!
Send money or beer vouchers for more/better help
Cheers,
Hein van den Heuvel ( at gmail )
More information about the Info-vax
mailing list