PreviousBtrieve API Guide (v9 SP2 (9.5) revision 1) Next

Open (0)

Chapter contents

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

 
Op Code
Pos Block
Data Buf
Data Buf Len
Key Buffer
Key Number
Sent

 

Returned
 

       

Prerequisites
Procedure
  1. Set the Operation Code to 0.
  2. If the file has an owner, specify the owner name, terminated by a binary 0, in the Data Buffer parameter.
  3. Specify the length of the owner name, including the binary 0, in the Data Buffer Length parameter.
  4. Place the pathname of the file to open in the Key Buffer parameter. Terminate the pathname with a blank or binary zero. 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 file into 255 bytes including the null terminator.

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.

Pervasive.SQL 2000 added support for long pathnames with spaces based on a client configuration option, "Embedded Spaces". By default, this configuration parameter is set to Off, which means spaces maybe be considered a delimiter. With this parameter set to On, spaces are considered part of the path, and a null byte must delimit the filename.

For more information about path names transactional interface supports, refer to Getting Started With Pervasive PSQL.

  1. In the Key Number parameter, specify one of the mode values listed in Table 2-17 .
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 2-17 Open Modes 
Open Mode Description
No preference
Force local engine
Force remote engine
Normal
 0
6
99
Accelerated
To improve performance on specific files, you can open a file in Accelerated mode. (The 6.x transactional interface accepted Accelerated mode opens, but interpreted them as Normal opens.) When you open a file in Accelerated mode, the transactional interface does not perform transaction logging on the file. See the caution above.
NetWare developers: Opening a file in Accelerated mode cancels the effect of flagging a file as transactional. (On other platforms, the transactional interface ignores the file's NetWare TTS flag.)
-1
7
100
Read-Only
When you open a file in Read-Only mode, you can only read the file; you cannot perform updates. This mode allows you to open a file with corrupt data that the transactional interface cannot automatically recover. If the data in the file's indexes has been corrupted, you can retrieve the records by opening the file in Read-Only mode and then using the Step Next (24) operation.
-2
8
101
Verify
This mode is ignored. If you specify this mode, the transactional interface opens the file in Normal mode. In previous versions of the transactional interface, Verify mode verified that the data written to disk was correct.
-3
N/A
N/A
Exclusive
Exclusive mode gives an application exclusive access to a file. No other application can open that file until the application that has exclusive access to the file closes it.
-4
10
103

The transactional interface allows a maximum of 250 open files, but you might be unable to open that many files due to limitations on system resources.

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.


Note
When the NetWare server transactional interface opens an extended file, it enforces NetWare security on the base file, but not on the extension files. In the rare event that a user has NetWare rights to a base file, but not the extension files, NetWare security can be violated. For workstation engines, NetWare does enforce security; therefore, such a user would not have access to the 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:

2

The application encountered an I/O error.

11

The specified filename is invalid.

12

The transactional interface cannot find the specified file.

20

The transactional interface or Btrieve Requester is inactive.

46

Access to the requested file is denied.

84

The record or page is locked.

85

The file is locked.

86

The file table is full.

87

The handle table is full.

88

The application encountered an incompatible mode error.

The following tables show the possible combinations for open modes involving local clients.

Table 2-18 shows open modes involving local clients.

Table 2-18 Open Mode Combinations for Local Clients
Open Mode for Local Client 1
Open Mode for Local Client 2
Result
Normal
Normal
Successful
 
Read-Only
Successful
 
Exclusive
Status Code 88
 
Accelerated
Successful
Read-Only
Normal
Successful
 
Read-Only
Successful
 
Exclusive
Status Code 88
 
Accelerated
Successful
Exclusive
Normal
Status Code 88
 
Read-Only
Status Code 88
 
Exclusive
Status Code 88
 
Accelerated
Status Code 88
Accelerated
Normal
Successful
 
Read-Only
Successful
 
Exclusive
Status Code 88
 
Accelerated
Successful

Positioning

An Open operation does not establish any positioning except that the physical next record becomes the first physical record of the file.


Chapter contents
Book contents

Prev topic: Login/Logout (78)
Next topic: Reset (28)