1751871 Members
5402 Online
108782 Solutions
New Discussion юеВ

Re: RMS indexed files.

 
SOLVED
Go to solution
Yyrkoon
Advisor

RMS indexed files.


Hi all, I'm having quite problems trying to solve and issue with RMS files. The problem is the following. I have an indexed file with both, primary and alternate key, I want to retrieve all registers with same alternate key, of course I can do a sequential read and retrive them, but it seems quite inefficient, C is able to locate first register with an specified alternate key. Can it not locate next record with same altenate key?? It is hard to believe, but trusting some examples it can not.

Do you know if it is possible to do what I want to? if so, How?

Thanks in advance.
6 REPLIES 6
Hein van den Heuvel
Honored Contributor
Solution

Re: RMS indexed files.

RMS is perfectly happy to help you read all records with the same alternate key.
Here is what you have to do:

SYS$OPEN the file
SYS$CONNECT a RAB
SET: RAB$B_KRF to the desired key NUMBER (1?)
SET: RAB$L_KBB/RAB$B_KSZ to the target key VALUE
SET: RAB$B_RAC to RAB$C_KEY

Do the first SYS$GET or an initial SYS$FIND
GET will deliver the data as decscribed in RBF/RSZ in the buffer set up by UBF/USZ.
SYS$FIND only positions. No data returned it typically allows for cleaner coding.

SET: RAB$B_RAB to RAB$C_SEQ
SET: RAB$V_LIM in RAB$L_ROP

LOOP: SYS$GET test for succes to know ther eis data, but also for RMS$_OK_LIM to know whether the end of the selected key value is reached without having to do the key fields compare yourself.

http://h71000.www7.hp.com/doc/731final/4523/4523pro_011.html#index_x_550



Please note the when retrieving a large (more than 5%?) portion of the whole file it may well be MORE efficient to read the whole file from start to finish with program or tool (DATATRIEVE, SORT, Vselect, DIX,...).

Hth,
Hein.



Hoff
Honored Contributor

Re: RMS indexed files.

There's an RMS library for C programming here:

http://labs.hoffmanlabs.com/node/1260

BSD-style license.

It doesn't use the OK_LIM stuff, but it can deal with sequential access and the keyed access.

John Gillings
Honored Contributor

Re: RMS indexed files.

Yyrkoon,

> but it seems quite inefficient

I'm not sure I understand the problem here. As per Hein's example, you read on the alternate key, then read sequentially to read further records with the same key value. Note that by RMS rules, they will be returned in temporal insertion order.

>but trusting some examples it can not.

Please post your example. Tell us what it's doing and what you expect.
A crucible of informative mistakes
Yyrkoon
Advisor

Re: RMS indexed files.

John, thanks, but I have already solve my issue.
Thanks to all, especially to the first guy answer (with such a weird name), it was an awesome explanation.
You and people like you make this page great!!
Craig A
Valued Contributor

Re: RMS indexed files.

Yyrkoon

I'm glad you have solved your particular problem. However, the principle of the forum is that we share knowledge and experiences.

To that end, it is very useful if you are able to explain what the problem was and how you fixed it.

This will help ensure that the forum is used on a 'give and take' basis.

Your comments about Hein's name made me smile. Don't exepct a call from the UN anytime soon :-)

Craig
Yyrkoon
Advisor

Re: RMS indexed files.

Craig,

The problem was exactly what I said, I was trying to find some alternate (and duplicate) keys but I didn't want to read all file sequentially, so I was looking for the right option for rab$l_rop but I found no good one. 'Cause although everything is very good documented in my humble opinion it should be more arrange. Eventually RAB$V_LIM was the option I was expecting to.

And I want to do just a small clarification about ... emmm ... about weird's name solution :-) after set rab$rop to v_lim it is necesary "activate" v_lim (xrab.rab$v_lim = 1;)

Thanks again to all you.