[Info-vax] Indexed RMS file question
DJ
daryljones at att.net
Sun Oct 4 07:00:59 EDT 2009
On Oct 2, 9:04 am, "J Xenu" <j_x... at hotmail.com> wrote:
> It's been a LONG time since I used indexed RMS files on VMS.
>
> 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.
>
> The lookups will be one of three methods:
>
> 1) Read a record that matches the first text key. Simple enough.
>
> 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.
>
> 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.
>
> 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
> Alpha 19-72 more data
> Beta 1-10 bla bla
> Beta 11 more stuff
> Beta 12-32 even more data
> Beta 33-50 This is the data I want
> Beta 68-100 xxx
> Gamma 1 yyy
> Gamma 2-140 zzz
>
> 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?
> The ranges are pseudo-random, not multiples of anything. There can be gaps as
> well, (for example "Beta", 62 in the example)
Dear J Xenu:
My suggestion to solve your problems is to have a primary key, first
field, be unique and be any thing you want of sequential order. Then
have you field2 be your data that contains: Alpha, Beta, or Gamma.
Your second field would contain your lower value of your range and the
next field, the third field, is your upper limit to your range, and
your fourth field is your data value. For example:
Field 1 Field 2 Field 3 Field 4 Field 5
Key0 Key1 Key2 Key3 Data Field
---------- ------------ -------- --------
----------------------------------------------
1 Alpha 0001 0018 Data
2 Alpha 0019 0072 More data
3 Beta 0001 0010 Bla bla
4 Beta 0011 0011 More stuff
5 Beta 0012 0032 Even more data
6 Beta 0033 0050 This is the data I
want
7 Beta 0068 0100 Xxx
8 Gamma 0001 0001 Yyy
9 Gamma 0002 0140 Zzz
Key 0 is primary key no duplicates.
Key 1, 2, 3 are secondary keys allow duplicates
Find Key1 = “Beta” where Key2 => 0042 and Key3 <= 0042; this should
return the value of “This is the data I want.”
Find Key1 = “Beta” where Key2 => 0033 and Key3 <= 0033; this should
return the value of “This is the data I want.”
Find Key1 = “Beta” where Key2 >= 0055 and Key3 <= 0055; this should
return the value of “Record not found”
You should create the file as sequential, fill it with data, and then
convert/sort the file to an index file with 4 keys.
I hope this helps you out. Good Luck!
Regards,
Daryl Jones
More information about the Info-vax
mailing list