Open (0)
The Open operation (B_OPEN) makes a file available for access. To access a file, your application must first perform an Open operation. The file does not have to reside in the current directory as long as you specify the full or relative pathname.
Parameters
 
Prerequisites
Procedure
1
2
3
Place the pathname of the file to open in the Key Buffer parameter. Terminate the pathname with a NULL (binary zero) depending on the setting for embedded spaces. The pathname can be up to 255 bytes. Any fully-qualified Unified Naming Convention (UNC) path name including the null terminator can be up to 255 bytes long.
The transactional interface normally expands the file name to a fully-qualified UNC file name. For example, J:\Data\File.dat would be converted to \\Servername\ShareName\Data\File.dat. This expanded name must fit into 255 bytes including the NULL terminator. See also Database URIs in Pervasive PSQL Programmer's Guide.
However, if the Btrieve Open request is sent to a local engine, the MIF will not replace the local drive letter with the computer name and share name. Even though you may get by with a longer path name if opened locally, remote clients may not be able to open the file.
Support for file names with embedded spaces based is enabled by a client configuration option, "Embedded Spaces." By default, this configuration parameter is set to On, which means spaces are considered part of the path. When the setting is On, a NULL byte must delimit the file name. When the setting is Off, you cannot use filenames that contain embedded spaces (such as "C:\My Folder\my file.mkd"). See Advanced Operations Guide (Long File Names and Embedded Spaces Support).
For details about path names supported by Pervasive PSQL clients, see Network Path Formats Supported by Pervasive Requesters in Getting Started With Pervasive PSQL.
4
Details
This section describes the open modes that are supported.
*Caution: The database engine cannot guarantee transaction atomicity, transaction durability, or archival log safety for any client during use of Accelerated mode by any client. The reason for this restriction is that in the event a restore from log is needed, the log may not contain adequate information to complete the restore, because it is only a partial record of operations on a data file.

For example, if a system failure occurs while the same file is being accessed by a client performing inserts using Accelerated mode and a client performing updates using Normal mode, it is possible for the transaction log to contain updates to records that do not yet exist in the data files, because the Accelerated insert operation in memory was never flushed to disk, while the transactional update operation was written to the transaction log.

An attempt to roll forward an archival log containing this combination of operations will fail.
When you open a file, you can instruct the transactional interface through the open mode to use either a local or remote engine. You specify the open mode in the Key Number parameter.
*Note: The Open operation makes no distinction between workstation, workgroup, and server engines when you specify that the local engine should open the file.
Table 24
There is no fixed limit on the maximum number of open files. The number of files that can be opened at once depends on the available memory.
A file is opened only once by the transactional interface. (The transactional interface recognizes and handles the situation in which more than one client at a time opens a file, or a single client has more than one Position Block in the file.) When you open an extended file, the transactional interface uses a single handle, and opens the base file and all extension files.
Result
If the Open operation is successful, the transactional interface assigns a file handle to the file, reserves the Position Block passed on the Open call for the newly opened file, and makes the file available for access.
If the Open operation is unsuccessful, the transactional interface returns one of the following status codes:
The following tables show the possible combinations for open modes involving local clients.
Table 25 shows open modes involving local clients.
Positioning
An Open operation does not establish any positioning except that the physical next record becomes the first physical record of the file.