C-ISAM switching indexes... Needhelp!
Posted in 1992
Topics: General Discussion
Hi, Although I have used C-ISAM for a few projects I do not consider myself proficient with the product. What I need is a technique that will enable me to switch between two (or more) indexes while retaining the current record position w ithin the data file. What I actually have to do is be able to position myself within the data file using a unique index and then use the secondary index to read sequentially from that already chosen starting position. e.g. st{char/int/long/etc}(values, all key fields) ; isstart(File, &MyUniqueKey, EntireKey, &Record, ISEQUAL) ; isread(File, &Record, ISCURR) ; /* should be pointing at first record unless doesn't exist */ isstart(File, &MyOtherKeyNotUnique, EntireKey, &Record, ISEQUAL) ; loop { isread(File, &Record, ISNEXT) ; DoSomethingWith(Record) ; } But when I try this the second "isstart" changes the record position away from the where the first "isstart" initiated it to be. Mi nd you the starting position is close. The new position after the second "isstart" is at the first occurance of the non-unique key e.g. : Given that in the following example "PartNo" is the unique key and "DateEntered" in the non-unique key the assignment is to return a ll "steamer's" entered on date "13-12-92". Unique non-key Non-unique PartNo Description DateEntered 1 1 litre pot 12-12-92 2 2 litre pot 13-12-92 <- position after second isstart 3 3 litre pot 13-12-92 4 4 litre pot 13-12-92 5 1 litre steamer 13-12-92 <- position after first isstart 6 2 litre steamer 14-12-92 ... stclong(5, &Record.PartNo) ; isstart(File, &PartNoKey, EntireKey, &Record, ISEQUAL) ; isread(File, &Record, ISCURR) ; /* should find the first "steamer" */ istart(File, &DateEnteredKey, EntireKey, &Record, ISEQUAL) ; isread(File, &Record, ISCURR) ; /* Jumps back to "2 litre pot" */ This must be an age old problem with C-ISAM programs which probably already has a work around so I feel a bit silly asking for a solution! Walter