Accessing Pervasive.SQL With Perl

Page Last Modified: 20/11/12

Home Links ODBC (DBI) Contact

Win32::API

Win32::API was created by Aldo Calpini, is maintained by Cosimo Streppone, and is available on CPAN and as part of ActivePerl for Windows. It allows you to call Windows DLLs from Perl provided you know the parameters required and the expected return values and is therefore a low-level interface. It is a useful fallback when you do not have a friendlier (and usually safer) XS to call for the required functionality.

Pervasive.SQL can be accessed by it's own low-level API (still referred to as the Btrieve API after the earlier name of the database system) supplied via the corresponding Pervasive DLL. This DLL, W3BTRV7.DLL, contains a number of functions - the most commonly called one is BTRCALL which is used with different operation codes and parameter combinations to perform the various database operations, such as:

Get first record (physical position or via specific index)
Get next record (physical position or via specific index)
Get record equal to key value for specific index
Get record greater/less than or equal to key value for specific index
Insert/update/delete record
Extended-get - retrieve a block of records, with optional key values and the ability to only get certain fields from each record
Lock record(s) or file
Start/commit/abort transaction

The Btrieve API was the original method of calling the database and is generally still the fastest. However, setting up complex queries has to be done entirely via the application's code, with none of the luxuries of SQL and database optimization entirely down to the application programmer's knowledge of the database schema, e.g. what indexes are available.

  1. The BTRCALL function
  2. Using BTRCALL in Win32::API
  3. BTRCALL (Btrieve API) status codes

Examples:

  1. Example 1 - getting version information
  2. Example 2 - parsing a table in DEMODATA

 

 

 

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2020