BTRIEVE
BTRIEVE is a ready-made record management system that allows
you to ignore physical file structures and concentrate on the logical structure of a file. Sunbelt's
implementation of BTRIEVE allows execution of all BTRIEVE
Functions by the PL/B program. BTRIEVE is not supported in
the Linux runtimes. Features and benefits of BTRIEVE
include:
Each data file may have up to 24 key fields or access paths. BTRIEVE
maintains separate internal indexes for each access path.
Files may be partitioned among different logical and/or physical drives. Both files must be available when attempting to access the data.
Support is included for duplicate, modifiable, segmented, null and descending keys.
Keys into the data may be added or dropped as necessary.
File size is restricted only by the available disk space.
All keys are maintained when the file is accessed.
Provisions are included for a relational database.
Two types of keys are supported - standard and extended. Standard keys are string (ASCII strings) and binary (unsigned 2 byte integers). Extended key types include IEEE floating point, zero terminated string, packed decimal, etc.
Transaction processing is supported.
Network data access (multi-user) capability is built into the BTRIEVE file I/O routines.
Data may be accessed in ascending or descending sequence dependent on the values of the designated key fields.
A relational structure may exist between BTRIEVE files.
A complete set of utilities is included with your BTRIEVE software (not from Sunbelt) to maintain and create BTRIEVE files. These include the ability to COPY the contents of one BTRIEVE file to another, DROP a supplemental index, create a supplemental index, etc.
The instruction uses the following format:
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
opcode
Required. A previously defined Numeric Variable or Expression representing the BTRIEVE Function Code
status
Required. A previously defined Numeric Variable returning the Btrieve status code (0 = Successful).
bfile
Required. A previously defined BFILE definition label.
buffer
Required. A previously defined Character String Variable or SKIP directive indicating the beginning of the input or output buffer space for BTRIEVE file I/O.
length
Required. A previously defined Numeric Variable or Expression representing the amount of data sent to or received from Btrieve.
key
Required. A previously defined Character String Variable representing a key value sent to or received from BTRIEVE.
keynum
Required. A previously defined Numeric Variable or representing the amount of data sent to or received from Btrieve.
Flags Affected: OVER
Note the following:
All calls to the BTRIEVE record manager return a status value. This value is placed in the variable {status}. You should always check the value of {status} after every BTRIEVE instruction. {status} is always a return value from BTRIEVE.
{bfile} is the BFILE declaration previously declared in the user data area. Its contents are initialized upon execution of a BTRIEVE OPEN operation. The BTRIEVE record manager references and updates this upon all file operations. Your application program must allocate a separate BFILE declaration for each BTRIEVE file it opens. Unlike conventional PL/B ISAM file I/O, if you have multiple indexes, you must only have one BFILE definition and thus execute only one open operation.
All data transferred from and to the BTRIEVE record manager use the {buffer} area. This is an area from 1 to n bytes in length (with 'n' not to exceed the maximum allowed by BTRIEVE). {buffer} must be a valid DIM or INIT variable and indicates the starting point of the total buffer. It is recommended {buffer} be setup using the SKIP parameter. {buffer} may be both a sending and receiving variable for BTRIEVE.
The actual amount of data passed from {buffer} to BTRIEVE or received from BTRIEVE is determined by {length}.
Dependent on the particular operation, {key} is the key value to or from the BTRIEVE record manager. {key} is both a sending and receiving variable for BTRIEVE.
You may have up to 24 different keys for each BTRIEVE file. {keynum} tells the BTRIEVE record manager that access path to follow for this particular operation. {keynum} is a FORM variable, INTEGER variable, an immediate value or an EQUated value with a range from 0 to 23. The BTRIEVE record manager does not alter the {keynum} field. {keynum} is an input field only for BTRIEVE and has other purposes for some of the BTRIEVE operations. See the BTRIEVE manual for more details.
The OVER flag is set if the BTRIEVE record manager cannot be accessed (i.e., BREQUEST has not been loaded for a workstation.
Network versions of BTRIEVE are not supported with SUNDB86L.
Functions:
The Btrieve operation code determines the type of BTRIEVE function to perform. The operation may be a read, write, delete, update, or other function. The variable specified must be a Numeric Variable, an Expression, an Equated value, or a decimal value. The application program is responsible for specifying a valid {opcode} on every BTRIEVE instruction. The BTRIEVE record manager never changes {opcode}. The valid opcode values and the operations they perform are:
|
Code |
Description |
|
0 |
OPEN a file for further access. |
|
1 |
CLOSE a previously opened file. |
|
2 |
INSERT a new record into the file. This not only writes the text data butalso inserts all applicable keys. In standard PL/B code, this would be a WRITE operation followed by the required number of INSERT instructions (if additional index files existed). |
|
3 |
UPDATE the current record in the file. As in the INSERT routine, the text data is updated and all applicable keys are updated (if necessary). |
|
4 |
DELETE the current record from the file, including the text data and all keys. In standard PL/B, this would be a DELETE, followed by the required number of DELETEK instructions (if additional index files existed). |
|
5 |
Get the record that meets the key specification given. This is equivalent to an ISAM read. |
|
6 |
Get the next record (key sequentially) in the file. Equivalent to a READKS operation. |
|
7 |
Get the previous record (key sequentially). In PL/B, this is would be a READKP instruction. |
|
8 |
Get the record whose key value is greater than the specified key value. Equivalent to an ISAM READ (record found) followed by a READKS. |
|
9 |
Get the record whose key value is equal to or greater than the specified key value. |
|
10 |
Retrieve the record whose key value is less than the specified key value. Equivalent to an ISAM READ (record found) followed by a READKP. |
|
11 |
Get the record whose key value is equivalent to or less than the specified key value. |
|
12 |
Get the record with the first key value. |
|
13 |
Get the record with the last key value. |
|
14 |
Creates a BTRIEVE file with the specified characteristics. Unlike conventional PL/B, creating (PREP) of a file does not make it available for access. You must still OPEN the file before performing I/O against it. |
|
15 |
Get status information about a file. Information is returned indicating the number of records and keys in the file. |
|
16 |
Allows you to extend a BTRIEVE file across two logical or physical volumes. When you go to access the file, both portions of the file must be available. |
|
17 |
Changes your current directory to the specified path. |
|
18 |
Returns the path of your current directory. |
|
19 |
Start a set of related operations. Indicates the start of a 'transaction'. |
|
20 |
End the set of related operations. Indicates the end of a 'transaction'. |
|
21 |
Aborts the current active 'transaction'. All operations performed since the start operation are removed from the file. |
|
22 |
Return the position of the current record. |
|
23 |
Retrieve the record at a specified position. |
|
24 |
Get the record in the physical location following the current read. |
|
25 |
Terminates the memory resident BTRIEVE file handler program at a workstation. |
|
26 |
Retrieve the current BTRIEVE BREQUEST version and revision numbers. |
|
27 |
Release a previously locked record. |
|
28 |
Release all resources held by a workstation. |
|
29 |
Sets the owner of a file, thus preventing unauthorized access. |
|
30 |
Clears the owner of a file. |
|
31 |
Create a supplemental index into a file. |
|
32 |
Removes a supplemental index from a file. |
|
+100/+300 |
Get a record and lock it after it becomes available. If the record is currently locked, the BTRIEVE record manager waits before returning. |
|
+200/+400 |
Get a record and lock it. If already locked, a non-zero status is returned. |
Example:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
| ||
|
| ||
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
| ||
|
| ||
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
| ||
|
| ||
This example program opens, reads, and writes to a Btrieve file.
See Also: Disk I/O Instructions
![]() |