Skip to content

Using Database Access with the DataFlex Pervasive.SQL Driver

The driver can be configured to operate in database mode or in non-database mode. This is specified by the DATABASE_MODE setting in the driver configuration file DFBTRDRV.INT.

When running in database mode (DATABASE_MODE is on), the driver accesses tables by specifying a database name in a URI.

When running in non-database mode (DATABASE_MODE is off), the driver functions the same as earlier versions of the driver. Tables are located by searching the data path (DFPATH) or using the BTR_PATH setting.

The DATABASE_MODE setting can only be on when Pervasive.SQL V8.5 or later is used. If the setting is on, all tables must be accessed in database mode using URIs. It is not possible to use both database access and non-database access.

When using the driver with Pervasive.SQL versions before V8.5, the DATABASE_MODE setting must be off.

Although URIs are mainly intended to access secured databases, they can also be used to access unsecured databases (but only on Pervasive.SQL 8.5 or later). When accessing unsecured databases, OS-level (Windows) user names can be specified in the URI.

If DATABASE_MODE is on, the driver does not need to know where the BTR and DDF files are located, since this is specified by the database name in the URI. For this reason, the data path (DFPATH) will not be searched, and the BTR_PATH and DDF_PATH settings will not be used.

Note that the driver still must be able to access the intermediate (INT) files and structure cache (CCH) files when using databases. These files must be located in a central accessible place, where the driver can access them.

The CCH and INT files can be (and preferably are) in a different location than the BTR and DDF files.

Opening Tables in Database Mode

Opening a table in database mode requires specification of a URI. URIs for individual tables must be specified in the intermediate (.INT) file for the table with the URI keyword.

The following is an example of the intermediate file SALESP.INT that can be used to access the table SALESP in the database "Order" on the server "MyPervasiveServer":

DRIVER_NAME DFBTRDRV
URI btrv://psqluser@MyPervasiveServer/Order?table=salesp&pwd=secret
; Data after this point is read after the DDF's have been read
; ID
FIELD_NUMBER 1
FIELD_INDEX 1
; NAME
FIELD_NUMBER 2
FIELD_INDEX 2

Open As with a URI

In a normal open, the driver expects the name of the intermediate file in the root name of the table in filelist.cfg. The root name can be specified as the name of the intermediate file (SALESP.INT) or with a driver prefix (DFBTRDRV:SALESP).

Alternatively, when using an "Open As" command, the root name can be specified in the command itself.

Example

Open "SALESP.INT" as hFile
Open "DFBTRDRV:SALESP" as hFile

All of the above open methods require an INT file with a URI specified.

In addition, the driver allows specification of a URI in the Open As command as follows:

Open "DFBTRDRV: btrv://psqluser@MyPervasiveServer/Order?table=salesp&pwd=secret" as hFile

This "URI Open As" command will open the table as specified by the URI. The "URI Open As" can use an intermediate file but does not necessarily have to.

An intermediate file will be used if:

  • USE_INT in DFBTRDRV.INT is on, and
  • An .INT file can be found.

If an .INT file is found and it contains a URI, that URI will not be used; instead, the URI of the "Open As" command will be used. All other information from the .INT file (like relations) will be used.

The "URI Open As" will not use an intermediate file if:

  • USE_INT in DFBTRDRV.INT is off, or
  • An .INT file cannot be found.

An "URI Open As" will use the table name from the URI as the base name for the intermediate file (.INT) and the structure cache file (.CCH).

Note

The special driver Open As method:

Open "LOGIFILE|PHYSFILE.BTR" as hFile

is not supported when DATABASE_MODE is on.