Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Equal / Get Next

Status
Not open for further replies.

senorbuckwheat

Programmer
Jul 12, 2002
17
0
0
US
Hi,

Using the Btrieve API, I do a GET_EQUAL command on a Btrieve table. I set the OpCode, PosBlock, DataBufLen, KeyBuffer, and KeyNumber and then execute the command.

If a record is found that matches the key, I do some processing and then do a GET_NEXT to get the next record that matches the key and so on.

The problem is that the GET_NEXT gets records that does not match the key after all the records that match the key have been read.

It seems once it establishes a position in the file based on the key during the GET_EQUAL, it just keeps reading records sequentially using the GET_NEXT without regards to the key.

I work around it by checking the returned record values against key values after each GET_NEXT and then breaking when they do not match. But that seems to defeat the purpose of a GET_EQUAL,GET_NEXT using a key value.

Any suggestions would be welcomed.

Thank you.
 
Actually a GetNext, does exactly that. It gets the next record in the index path. It does not check the record to see if it matches the key value. This lets you traverse through the file completely. The StepNext operation gets the next physical record regardless of the index. info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
The documentation posted in the Pervasive API Programmer's Reference for the GET_NEXT is as follows:

Start ------------------------------------------------------
The Get Next operation (B_GET_NEXT) retrieves the record in the logical next position (based on the specified key). You can use the Get Next operation to retrieve records within a group of records that have duplicate key values.
End --------------------------------------------------------

If what I have experienced through my testing of my application, which is what your answer stated, the documentation is very vague on this issue. It mentions "retrieves the logical next position (based on the specified key)" but then mentions that the GET_NEXT can be used "to retrieve records within a group of records that have duplicate key values".

I guess the word "can" is the key (no pun intended) here. It "can" be used but it won't stop getting records once all the "the records that have duplicate key values" have been retrieved.

Anyway, thank you for your response to my question. At least now I know that I am handling the situation properly and it is not a problem in the way my application is executing the GET_NEXT command.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top