SQLAPI++
C++ library for interfacing with
multiple SQL databases
Portability

SQLAPI++ is a C++ library that provides unified API to access different SQL databases.

We support:

By encapsulating vendor APIs, SQLAPI++ library acts as middleware and delivers database portability.

Easy to Use, Easy to Deploy

Using the library saves you time and effort by taking away the complexity of native C APIs provided by database clients.

No need to install and configure OLEDB and/or ODBC drivers when developing and distributing your applications.

Extensibility and Support

The library provides a low-level interface to access database-specific features should that become necessary.

Library supports database connectivity on Windows, Linux/Unix and MacOS.

SQLAPI++ ships with all the sources.

We provide free ongoing email support, one year of bug fixing and new version updates.


Connect to Database

Just make a call to SAConnection::Connect and provide the credentials. SQLAPI++ does the rest by dynamically loading specified client's native library and calling corresponding APIs.

SAConnection con;
con.Connect( "demo", "guest", "secret", SA_SQLServer_Client );

Insert Data into a Table

To insert data create SACommand, bind input variables as needed using stream operators and call SACommand::Execute to send command to the server. SQLAPI++ takes care of preparing and executing the command using navite APIs when needed.

SACommand insert(&con, "INSERT INTO EMPLOYEES (NAME, AGE) VALUES (:1, :2)");

insert << "Tom Patt" << 30L;
insert.Execute();
insert << "Nick Barry" << 35L;
insert.Execute();

Read Data from a Table

To read data execute a SELECT command, bind WHERE clause variables as needed and use SACommand::FetchNext in a loop to retrieve all the rows. SQLAPI++ does the hard work of interfacing with native APIs, allocating buffers, etc.

SACommand select(&con, "SELECT NAME, AGE FROM EMPLOYEES WHERE AGE > :1");

select << 30L;
select.Execute();

while(select.FetchNext()) {
    SAString sName = select[1];
    long nAge = select[2];
    printf("Name: %s, age: %d \n", sName, nAge);
}

More Examples

Example 1.Connecting to database (and error handling)
Example 2.Executing a simple SQL command
Example 3.Binding input parameters
Example 4.Executing a select query (and fetching result set)
Example 5.Binding LongBinary, LongChar, BLob and CLob data
Example 6.Fetching LongBinary, LongChar, BLob and CLob data
Example 7.Multi-threading support and canceling queries
Example 8.Fetching records in bulk
Example 9.Using Oracle REF CURSORs
Example 10.Using Oracle nested cursors

Compatibility

SQLAPI++ library supports the following C/C++ compilers:

  • Microsoft Visual C++
  • Embarcadero (Borland) C++
  • GNU GCC C++ compiler
  • Solaris Studio C++ compiler

Latest Release

5.0.2
November 15, 2019
General CubeSQL MySQL ODBC Oracle SQL Server SQLBase
New Features
  • SQLBase: Added option "SQLBaseUseDoubleForDecimal"
  • Oracle: Alwasy use timezone infromation when read date/time values with timezone
  • MySQL: Added version 8.x mysqlclient name into default library list (thanks Leo Namuco​)
  • General: Removed SAOptions::Option(int) method but added SAOptions::OptionName(int) one (thanks Christian Schmitz)
Bug Fixes
  • General: Fixed SAOptions::Option method bug, the problem with thread-safe execution (thanks Peter Klotz)
  • CubeSQL: Fixed "SHOW..." command execution (thanks Christian Schmitz)
  • MySQL: Fixed environment initialization flag initial value (thanks Peter Klotz)
  • ODBC: Fixed error message generation for Unicode Linux/Unix version (thanks Christian Schmitz)
  • MySQL: Fixed "UseMySQLKillQueryConnection" option processing
  • SQL Server (ODBC): Fixed bug with string truncation in Unicode version for Linux (thanks Jürgen Thoma)
  • General: Fixed SAPI initialization related memory leak (thanks Baerten Manuel)
  • SQL Server (ODBC): Fixed API loading on Linux
  • CubeSQL: Fixed crashing when the result set fields described without command executed (thanks Christian Schmitz)

See full history...