[Lazarus] MWA Software's Firebird Pascal API

Tony Whyman tony.whyman at mccallumwhyman.com
Wed Dec 7 12:09:14 CET 2016


I've copied the following announcement to this list because of the 
discussions that took place earlier this year on use of Pascal 
Interfaces. The background for my interest in the subject was the 
development of this package and which I believe really does show the 
power of Pascal interfaces - for the package user. When I started 
developing this API, it was meant to be an internal interface to IBX2, 
but once developed it became clear that the use of interfaces had 
provided a powerful means to effectively embed SQL in a Pascal program 
with very little effort from the user. Hopefully, this package will be 
useful to others.

Tony Whyman

MWA Software

Announcement follows:

MWA Software is pleased to announce the release of its Firebird Pascal 
API package (/fbintf/). This package has been derived from IBX for 
Lazarus and is part of the IBX2 development (see separate announcement). 
The intent is to provide common Pascal language bindings to the Firebird 
API that are independent of the Firebird API version. The IBX derived 
code is licensed under the Interbase Public License, with the remaining 
code licensed under the Initial Developer's Public License.

The /fbintf/ package provides the Firebird API in a format where all 
data types for SQL data, interface parameters and results are native 
Pascal types, including all parameter blocks and database information. 
The Pascal API is pitched at a similar level and purpose to the IBPP 
Firebird API provided to the C++ world. The package is intended to be 
suitable for use on any platform supported by the Free Pascal Compiler. 
It is a required dependency for version 2 onwards of /IBX for Lazarus/, 
and is provided as both a standalone package and as part of IBX2.

It is available for download from http://www.mwasoftware.co.uk/ibx2.

The Firebird Pascal API is intended to be simple to use and to place the 
minimum burden on the API user when it comes to managing the Firebird 
client library and the various Pascal objects that are created to 
provide the API. It is implemented as reference counted COM interfaces 
which, for the API user, are as easy to use as other managed types such 
as AnsiStrings and dynamic arrays. The user only needs to worry about 
accessing and using the interface; disposing of interfaces is performed 
automatically whenever an interface goes out of scope. It is intended to 
be a full implementation of the Firebird API, including events, 
services, blobs and arrays.

Two interface implementations are provided. One is for the new Firebird 
3 Client API and the other for the legacy Firebird Client API used for 
Firebird 2.x and earlier. The Firebird 3 API implementation is used 
whenever possible and the older API only if the Firebird 3 API is not 
available.

The package is supported by an 89 page User Guide and a comprehensive 
test suite. The test suite includes 16 separate tests covering 104 
individual test objectives. It is console mode and run from a batch 
script with automatic comparison against a reference results log. It 
uses the “heaptrc” unit to check for memory leaks. The objective of the 
test suite is to provide confidence in the correct operation of the 
software over are variety of platforms and with only expected variances 
between the two Firebird APIs. It is also intended to be the basis for 
regression testing. Documentation on the use of the test suite is 
provided with the package.

Given the level at which the package works and the power of Pascal 
“interfaces”, embedded SQL statements are possible, such as:

Attachment.ExecuteSQL([isc_tpb_write, isc_tpb_nowait,isc_tpb_concurrency],
'Execute Procedure DELETE_EMPLOYEE ?', [8]);

and

writeln('Employee Count = ',
MyAttachment.OpenCursorAtStart('Select count(*) from 
EMPLOYEE')[0].AsInteger);

The /fbintf/package may be used on its own or as part of IBX and has the 
potential to provide a common Firebird API to all FPC database applications.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161207/279646de/attachment.html>


More information about the Lazarus mailing list