Get Next (6)
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. You can use the
Get Key (+50)
bias to detect the presence of a value in a file. A Get Key operation is generally faster.
Parameters
Op Code
Pos Block
Data Buf
Data Buf Len
Key Buffer
Key Number
Sent
Returned
Prerequisites
•
The file must be open.
•
The file cannot be a data-only file.
•
Your application must have an established logical next position based on the specified key.
Procedure
1
Set the Operation Code to 6. Optionally, you can include a lock bias:
•
+100—Single wait record lock.
•
+200—Single no-wait record lock.
•
+300—Multiple wait record lock.
•
+400—Multiple no-wait record lock.
For more information about locking, refer to the
Pervasive PSQL Programmer's Guide
.
2
Pass the Position Block for the file.
3
Set the Data Buffer Length to a value greater than or equal to the length of the record you want to retrieve.
4
Specify the key value from the previous operation in the Key Buffer.
Pass the Key Buffer exactly as the transactional interface returned it on the previous call, because the transactional interface may need the information previously stored there to determine its current position in the file.
5
Set the Key Number parameter to the key path used on the previous call. You cannot change key paths using a Get Next operation.
Result
If the Get Next operation is successful, the transactional interface returns the record in the Data Buffer, the key value for the record in the Key Buffer, and the length of the record in the Data Buffer Length parameter.
If the Get Next operation is unsuccessful, the transactional interface returns one of the following status codes:
3
The file is not open.
6
The key number parameter is invalid.
7
The key number has changed.
8
The current positioning is invalid.
9
The operation encountered the end-of-file.
22
The data buffer parameter is too short.
82
The transactional interface lost positioning.
The operation returns Status Code 9 if the logical next position points beyond the end of the file.
Positioning
The Get Next operation establishes the complete logical and physical currencies and makes the retrieved record the current one.