Btrieve Operations


Open and Close

B_OPEN - Open (0)
B_CLOSE - Close (1)
B_GETDIR - Get Directory(18)
B_SETDIR - Set Directory (17)

Reading Standard

B_GFIRST - Get First (12)
B_GGT - Get Greater (8)
B_GGTE - Get Greater or Equal (9)
B_GNXT - Get Next (6)
B_GET - Get Equal (5)
B_GPRV - Get Previous (7)
B_GLSE - Get Less Than or Equal(11)
B_GLS - Get Less Than (10)
B_GLAST - Get Last (13)

Reading by Position

B_GETPOS - Get Position (22)
B_GETD - Get Direct (23)
B_STPD - Step Direct (24)

Read Modifiers

B_KEY - Get Key Only (+50)
B_LOCKW - Lock with Wait (+100)
B_LOCKNW - Lock with No Wait (+200)
B_MLOCKW - Multiple Lock with Wait (+300)
B_MLOCKNW - Multiple Lock with No Wait (+400)
B_UNLOCK - Unlock (27)

Updating

B_INS - Insert (2)
B_UPD - Update (3)
B_DEL - Delete (4)

Transactions

BTR_BEGTR - Begin Transaction (19)
BTR_ENDTR - End Transaction (20)
BTR_ABRTR - Abort Transaction (21)

System Control

BTR_RESET - Reset (28)
B_STOP - Stop Btrieve and free memory (25)
B_VER - Version (26)

File Creation and Manipulation

B_CREATE - Create (14)
B_STAT - Status (15)
B_SOWNER - Set Owner (29)
B_COWNER - Clear Owner (30)
B_CRSIDX - Create Supplemental Index (31)
B_DRSIDX - Drop Supplemental Index (32)
B_EXTEND - Extend (16)


B_OPEN - Open (00)

Purpose

To open the file. A full path may be specified.

Parameters

Ope cbk data data len key key no.
Expected 00
 
Owner Name
 
File Name topen
Returned
 
X
 
 
 
 

Description

If the file has a owner position it in the data buffer, terminated by space or binary zero.
The file name goes in the key buffer, terminated by space or binary zero.

Topen is the open type:

-1 Accelerated
-2 Read Only
-3 Verify, (only local, executes Dos verify).
-4 Exclusive
otherStandard

Current Positioning

No positioning is established.


B_CLOSE - Close (01)

Purpose

Closes File.

Parameters

Ope cbk data data len key key no.
Expected 01 X X X X X
Returned
 
X X X X
 

Current Positioning

Removes all positioning.


B_GETDIR - Get Directory(18)

Purpose

Retrieves the current directory. Returns the current directory for a specified logical drive.

Parameters

Ope cbk data data len key key no.
Expected 18 X X X X X
Returned
 
X X X X
 

Description

Btrieve returns the current directory, terminated by a binary 0 to the key buffer. The key buffer must be at least 64 characters long.

Current Positioning

ºDoes not affect current positioning.


B_SETDIR - Set Directory (17)

Purpose

This operation set the current directory to a specified value.

Parameters

Ope cbk data data len key key no.
Expected 17
 
 
 
X
 
Returned
 
 
 
 
 
 

Description

It stores the desidered drive and directory path terminated with a binary 0.If you do not specify the complete path for the directory, Btrieve appends the specified directory path to the current directory.

Current Positioning

Set Directory has no effect on positioning


B_GFIRST - Get First (12)

Purpose

Retrieves the record corresponding to the first key value for a specified access path.

Parameters

Ope cbk data data len key key no.
Expected 12 X
 
X
 
X
Returned
 
X X X X
 

Description

Enables your application to retrieve a record which corresponds to the first key value for a specified key number. Btrieve returns the request record in the data buffer and stores the corrisponding key value in the key buffer. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • The previous record points beyond the beginning of the file
  • The next record becomes the next duplicate of the key value returned. If no duplicates exist for that key value, the next record becomes the first record corresponding to the key value greater than the one returned.


B_GGT - Get Greater (08)

Purpose

Retrieves a record corresponding to a key value greater than the specified key value.

Parameters

Ope cbk data data len key key no.
Expected 08 X
 
X X X
Returned
 
X X X X
 

Description

Btrieve ascends the access path specified by the key number to find the first key value greater than the one request. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • If a duplicate exist the next record becomes the first duplicate of the key value returned, otherwise becomes the first record for the key value greater than the one returned
  • The previous record becomes the last duplicate of the key value less than the one returned. If no duplicate exist, it becomes the only record for the key value less than the one returned.


B_GGTE - Get Greater or Equal (09)

Purpose

Retrieves a record with a key value greater than or equal to a specific key value

Parameters

Ope cbk data data len key key no.
Expected 09 X
 
X X X
Returned
 
X X X X
 

Description

If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • The next record becomes the first duplicate of the key value returned if a duplicate exist, otherwise it becomes the first record for the key value greater than the one returned.
  • The previous record becomes the last duplicate of the key value less than the one returned. If no duplicates exist for the key value, the previous record becomes the only record for the key value less than the on returned.


B_GNXT - Get Next (06)

Purpose

Retrieves the record from a Btrieve file which file follows the currrent record in the key path.

Parameters

Ope cbk data data len key key no.
Expected 06 X
 
X X X
Returned
 
X X X X
 

Description

The application must pass the key buffer exactly as Btrieve returned it on the previous call. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

Btrieve uses the positioning established by the previous call to perform a get next operation. It updates the current positioning after a get next as follows :

  • The next record becomes the next duplicate of the key value corrisponding to the record returned. If no duplicates exist, the first record for the next value greater than the one returned becomes the next record.
  • The previous record becomes what was the current record when the call was initiated.


B_GET - Get Equal (05)

Purpose

Retrieves a record corresponding to a specific key value

Parameters

Ope cbk data data len key key no.
Expected 05 X
 
X X X
Returned
 
X X X
 
 

Description

Btrieve returns the length of the record in the data buffer length parameter. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • If a duplicate exist, the next record becomes the first duplicate of the key value returned, otherwise the next record becomes the first record for the key value greater than the one returned.
  • The previous record becomes the last duplicate of the key value less than the one returned, otherwise the next record becomes the only record for the key value less than the one returned.


B_GPRV - Get Previous (07)

Purpose

Retrieves the record which precedes the current record in the key path

Parameters

Ope cbk data data len key key no.
Expected 07 X
 
X X X
Returned
 
X X X X
 

Description

The application must pass the key buffer exactly as Btrieve returned it on the previous call since Btrieve may need the information previously stored in the key buffer to determine its current position in the file. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • The next record becomes what was the current record when the call was initiated.
  • the previous record becomes either the previous duplicate for the key returned, or the last duplicate of the key value less than the one returned.


B_GLSE - Get Less Than or Equal(11)

Purpose

Retrieves a record with a key value which is less than or equal to a specific key value.

Parameters

Ope cbk data data len key key no.
Expected 11 X
 
X X X
Returned
 
X X X X
 

Description

Btrieve first searches the access path for the specified key value. If it does not find the value, it descends the access path for the path specified by the key number to find the first key value less than the one request. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • If a duplicate exist, the next record becomes the first duplicate of the key value returned, otherwise the next record becomes the first duplicate for the the key value greater than the one returned
  • The previous record becomes the last duplicate of the key value less than the one returned. If no duplicates exist for that key value, the previous record becomes the only record for the key value less than the one returned.


B_GLS - Get Less Than (10)

Purpose

Retrieves a record corresponding to the key value which is less than a specified key value

Parameters

Ope cbk data data len key key no.
Expected 10 X
 
X X X
Returned
 
X X X X
 

Description

Btrieve descends the access path specified by the key number to find the first key value less than the one requested. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • If a duplicate exist the next record becomes the first duplicate of the key value returned, otherwise the next record becomes the first record for the key value greater than the one returned.
  • The previous record becomes the last duplicate of the key value less than the one returned. If no duplicates exist, the previous record becomes the only record for the key value less than the one returned.


B_GLAST - Get Last (13)

Purpose

Retrieves the corresponding to the last key value for a specified access path.

Parameters

Ope cbk data data len key key no.
Expected 13 X
 
X
 
X
Returned
 
X X X X
 

Description

If duplicate exist, the record returned is the duplicate, that is, the one inserted most recently. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • The next record points beyond the end of the file.
  • The previous record becomes the previous duplicate of the key value returned. If no duplicates exist for that key value, the previous record becomes the last duplicate for the key value less than the one returned.


B_GETPOS - Get Position (22)

Purpose

Returns the physical position of the current record

Parameters

Ope cbk data data len key key no.
Expected 22 X
 
 
 
 
Returned
 
X X X
 
 

Description

Btrieve returns the location of the record in the data buffer, and sets the data buffer length to 4 bytes. The position is a 4-byte binary value which is the record's byte offset into the file. Btrieve does not perform any disk I/O to process a get position request.

Current Positioning

A get position operation does not affect current positioning.


B_GETD - Get Direct (23)

Purpose

Retrieves the data record positioned at a specified physical adress in the Btrieve file.

Parameters

Ope cbk data data len key key no.
Expected 23 X X X
 
X
Returned
 
X X X X
 

Description

The application specifies the record's location as its 4-byte offset from the start of the file. It obtains the 4-byte offset of a record with the get position operation. If the record is too long Btrieve returns as much as it can with a status of 22.

Current Positioning

As follows:

  • The next record becomes the next duplicate of the key value returned if a duplicate exist, otherwise it becomes the first record for the key value greater than the one returned.
  • The previous record becomes either the previous duplicate for the key returned or the last duplicate of the key value less than the one returned.


B_STPD - Step Direct (24)

Purpose

Retrieves a record in the location phisically following the current record

Parameters

Ope cbk data data len key key no.
Expected 24 X X X X X
Returned
 
X X X X
 

Description

A Step direct operation immediatly after any get operation returns the record phisically following the record retrieved by the previous get operation. If the record is too long, Btrieve returns as much as it can with a status of 22.

Current Positioning

The step direct operation establishes no positioning.


B_KEY - Get Key Only (+50)

Purpose

Get key allows you to perform a get operation without actually retrieving a data record, and can be used with any of the following operation:

  • Get Equal (5)
  • Get Next (6)
  • Get Previous (7)
  • Get Greater (8)
  • Get Greater or Equal (9)
  • Get Less Than (10)
  • Get Less Than or Equal (11)
  • Get First (12)
  • Get Last (13)

Parameters

Add value to get operation. Other parameters are the same as those specified in the get operation.

Current Positioning

Establishes the current positioning exactly as the corresponding get operation does, except that get next key and get previous key do not return duplicates.


B_LOCKW - Lock with Wait (+100)

Purpose

Gets a record and locks it. A single record wait lock.

Parameters

Add value to get operation. Other parameters are the same as those specified in the get operation.

Description

If another station has the record locked or has a transaction pending for the file, Btrieve waits until the record is available before returning control to the application. When you want to specify a wait transaction, set the operation code to 119.

B_LOCKNW - Lock with No Wait (+200)

Purpose

Lock, with the nowait option, gets a record and locks it. A single record nowait lock.

Parameters

Add value to get operation. Other parameters are the same as those specified in the get operation.

Description

If another station has the record locked or as a transaction pending for the file, Btrieve immediately returns a status of 84 ,indicating that the lock is busy. You may also issue a nowait begin transaction request with an operation code of 219.


B_MLOCKW - Multiple Lock with Wait (+300)

Purpose

Gets a record and locks it. A multiple record wait lock.

Parameters

Add value to get operation. Other parameters are the same as those specified in the get operation.

Description

If another station has the record locked or has a transaction pending for the file, Btrieve waits until the record is available before returning control to the application. When you want to specify a wait transaction, set the operation code to 319.


B_MLOCKNW - Multiple Lock with No Wait (+400)

Purpose

Lock, with the nowait option, gets a record and locks it. A multiple record nowait lock.

Parameters

Add value to get operation. Other parameters are the same as those specified in the get operation.

Description

If another station has the record locked or as a transaction pending for the file, Btrieve immediately returns a status of 85 ,indicating that the lock is busy. You may also issue a nowait begin transaction request with an operation code of 419.


B_UNLOCK - Unlock (27)

Purpose

The Unlock operation unlocks on or more records that were previously locked.

Parameters

Ope cbk data data len key key no.
Expected 27 X X X
 
X
Returned
 
 
 
 
 
 

Description

To unlock one multiple type record lock, complete the following steps:

  1. Get the position of the record you want to unlock by issuing a get position operation (22) for that record.
  2. Store the 4-byte position that Btrieve returns in the data buffer
  3. Set the operation code to 27 and pass Btrieve the position block for the file that contains the locked record.
  4. Store the 4-byte position of the record in the data buffer, and initialize the key number parameter to -1. Set the data buffer length to four.

Current Positioning

The unlock does not change positioning information.


B_INS - Insert(02)

Purpose

The insert operation, inserts a record into a file.

Parameters

Ope cbk data data len key key no.
Expected 02 X X X
 
X
Returned
 
X
 
 
X
 

Description

Btrieve adjust all the key indexes to reflect the key values for the newly inserted record at the time record is inserted.

Current Positioning

As follows:

  • The first data record for the key value greater than the key just inserted becomes the next record.
  • The last data record for the key value less than the key just inserted the previous record.


B_UPD - Update (03)

Purpose

Updates an existing record in a Btrieve file.

Parameters

Ope cbk data data len key key no.
Expected 03 X X X
 
X
Returned
 
X
 
X X
 

Description

Your application must retrieve the record to be update by using one of the get operations on the call immediately preceding an update operation. Btrieve then adjusts the key indexes to reflect any change in the key values. It also updates the key buffer parameter if necessary.

Current Positioning

As follows:

  • The first record with a key value greater than the updated key becomes the next record.
  • The first record with a key value less than the updated key becomes the previous record.


B_DEL - Delete (04)

Purpose

Removes an existing record from a Btrieve file.

Parameters

Ope cbk data data len key key no.
Expected 04 X
 
 
 
X
Returned
 
X
 
X
 
 

Description

To delete records your application retrieves the record to be deleted on the call immediately preceding the delete operation.

Current Positioning

As follows:

  • The next record becomes either the duplicate following the deleted record or the first data record for the key value greater than the key just deleted.
  • The previous record becomes either the previous duplicate or the last data record for the key value less than the key just update.


BTR_BEGTR - Begin Transaction (19)

Purpose

Marks the beginning of a set of logically related Btrieve operations.

Parameters

Ope cbk data data len key key no.
Expected 19
 
 
 
 
 
Returned
 
 
 
 
 
 

Description

Defines the start of a transaction, which can include any number of Btrieve operations on up to twelve different files.

Current Positioning

A begin transaction has no effect on positioning information.


BTR_ENDTR - End Transaction (20)

Purpose

Completes a transaction and makes the appropriate changes to affected data files.

Parameters

Ope cbk data data len key key no.
Expected 20
 
 
 
 
 
Returned
 
 
 
 
 
 

Description

A successful end transaction means that all of the operations bracketed within the transaction have been recorded in your database. The application cannot abort a transaction after the end transaction operation.

Current Positioning

An end transaction operation does not affect positioning information.


BTR_ABRTR - Abort Transaction (21)

Purpose

Removes all operations performed since the beginning of an active transaction and terminates the transaction.

Parameters

Ope cbk data data len key key no.
Expected 21
 
 
 
 
 
Returned
 
 
 
 
 
 

Description

Abort transaction removes all operations performed after the start of the previous begin transaction operation, and terminates the current transaction.

Current Positioning

An abort transaction operation has no effect on positioning information.


BTR_RESET - Reset (28)

Purpose

Releases all resources held by a station, such as locks left pending by an abnormal termination of an application.

Parameters

Ope cbk data data len key key no.
Expected 28
 
 
 
X X
Returned
 
 
 
 
 
 

Description

If the application is releasing resources for another station on the network, set the key number parameter to -1. Store the connection number of the station to be reset as an integer in the first 2 bytes of the key buffer.

Current Positioning

The reset operation destroys all positioning information because it closes any open files.


B_STOP - Stop Btrieve and free memory (25)

Purpose

The stop operation terminates Btrieve.EXE and removes it from memory.

Parameters

Ope cbk data data len key key no.
Expected 25
 
 
 
 
 
Returned
 
 
 
 
 
 

Description

If Btrieve is the highest memory resident program loaded, the stop operation deallocates all the memory previously allocated to Btrieve. The application cannot perform any other Btrieve operations until you restart Btrieve.

Current Positioning

The stop operation does not establish a current position.


B_VER - Version (26)

Purpose

It returns the current Btrieve version and revision numbers.

Parameters

Ope cbk data data len key key no.
Expected 26
 
 
 
 
 
Returned
 
 
X
 
 
 

Description

Btrieve returns the data to the data buffer in the following format:

2 Integer containing version number
2 Integer containing revision number
1 Character containing:
'N' for Network Btrieve or
blank for Btrieve single User

Current Positioning

A version operation does not affect current positioning.


B_CREATE - Create (14)

Purpose

This operation allows to generate a Btrieve file from within your application program.

Parameters

Ope cbk data data len key key no.
Expected 14 X X X X
 
Returned
 
X
 
X
 
 

Description

Btrieve expects the information in the following format:

File specs:

Description Length
Record length 2
Page size 2
# of indexes 2
Not used 4
File flags 2
Reserved word 2
Allocation 2

Key specs:

Description Length
Key position 2
Key length 2
Key flags 2
Not used 4
Extended key type 1
Null value 1
Reserved 4

Current Positioning

A create operation does not establish any positioning information.


B_STAT - Status (15)

Purpose

Retrieves the characteristics for a specified file.

Parameters

Ope cbk data data len key key no.
Expected 15 X
 
X
 
X
Returned
 
 
X X X
 

Description

Btrieve returns the data buffer in the format shown below.

File specs:

Description Length
Record length 2
Page size 2
# of indexes 2
# of record 4
File flags 2
Reserved word 2
Unused pages 2

Key specs:

Description Length
Key position 2
Key length 2
Key flags 2
# of key 4
Extended key type 1
Null value 1
Reserved 4

Current Positioning

The stat operation does not affect positioning.


B_SOWNER - Set Owner (29)

Purpose

Assigns an owner name to a file to prevent unauthorized access.

Parameters

Ope cbk data data len key key no.
Expected 29 X X X X X
Returned
 
X
 
 
 
 

Description

You must open the file before you can perform a set owner operation. Once set a owner name, it remains in effect until issue a clear owner operation. You cannot issue a set owner operation during a transaction.

Possible values for the key number are:

0 Requires owner name for any access (no data encryption)
1 Permits read-only access without owner name (no data encryption)
2 Requires owner name for any access (data encryption)
3 Permits read-only access without owner name (data encryption)

Current Positioning

Set owner has no effect on position


B_COWNER - Clear Owner (30)

Purpose

Removes the owner name associated with a Btrieve file.

Parameters

Ope cbk data data len key key no.
Expected 30 X
 
 
 
 
Returned
 
X
 
 
 
 

Description

After a clear owner operation, Btrieve no longer requires the owner name. If you previously encrypted the data in the Btrieve file when you assigned the owner, btrieve decripts the data during a clear owner operation. The more data that Btrieve has to decrypt, the longer the clear owner operation takes.

Current Positioning

Clear owner has no effect on positioning.


B_CRSIDX - Create Supplemental Index (31)

Purpose

This operation adds a supplemental index to an existing Btrieve file

Parameters

Ope cbk data data len key key no.
Expected 31 X X X
 
 
Returned
 
 
 
 
 
 

Description

The data buffer consist of a 16-byte key specification block for each segment of the supplemental index you are creating. Use the same structure as the key specification block you use in the create operation.

Current Positioning

The create supplemental index operation has no effect on positioning.


B_DRSIDX - Drop Supplemental Index (32)

Purpose

Removes a supplemental index from an existing Btrieve file.

Parameters

Ope cbk data data len key key no.
Expected 32 X
 
 
 
X
Returned
 
 
 
 
 
 

Description

To drop a supplemental index, the Btrieve file must be open. When Btrieve drops a supplemental index, the file pages that were allocated to that index are placed on a list of free space and are reused when you insert records or create another index. If the file has supplemental indexes with key numbers higher than the index that was dropped, Btrieve decrements those key numbers by one.

Current Positioning

The drop supplemental index operation has no effect on positioning.


B_EXTEND - Extend (16)

Purpose

Allows your application to expand a single Btrieve file to a second logical disk drive.

Parameters

Ope cbk data data len key key no.
Expected 16 X
 
 
X X
Returned
 
X
 
 
 
 

Description

The Btrieve file must be opened before it can be extended. It's not possible extend a file during a transaction. If you want Btrieve to begin storing data in the extension file, specify a value of -1 in the key number parameter when you perform the extended operation.

Current Positioning

This operation does not affect current operation.


btrv_operations.html