Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - Programming » SQL Anywhere database API for C/C++

SQL Anywhere C API support

The SQL Anywhere C Application Programming Interface (API) is a data access API for the C / C++ languages. The C API specification defines a set of functions, variables and conventions that provide a consistent database interface independent of the actual database being used.

Using the C API, your C / C++ applications have direct access to databases running on SQL Anywhere database servers.

The C API is layered on top of the DBLIB package and it is implemented with Embedded SQL. Although it is not a replacement for DBLIB, the C API simplifies the creation of applications using C and C++. You do not need an advanced knowledge of Embedded SQL to use the C API.

The C API also simplifies the creation of C and C++ wrapper drivers for several interpreted programming languages including PHP, Perl, Python, and Ruby.

API distribution

The API is built as a dynamic link library (DLL) (dbcapi.dll) on Microsoft Windows systems and as a shared object ( on Unix systems. The DLL is statically linked to the DBLIB package of the software version on which it is built. When the dbcapi.dll file is loaded, the corresponding dblibX.dll file is loaded by the operating system. Applications using dbcapi.dll can either link directly to it or load it dynamically.

Descriptions of the C API data types and entry points are provided in the sacapi.h header file which is located in the sdk\dbcapi directory of your software installation.

Threading support

The C API library is thread-unaware; the library does not perform any tasks that require mutual exclusion. To allow the library to work in threaded applications, only one request is allowed on a single connection. With this rule, the application is responsible for doing mutual exclusion when accessing any connection-specific resource. This includes connection handles, prepared statements, and result set objects.

C API examples

Examples that show how to use the C API can be found in the sdk\dbcapi\examples subdirectory of your database software installation.

  • callback.cpp

    This is an example of how to create and use callbacks.

  • connecting.cpp

    This is an example of how to create a connection object and use it to connect to a database.

  • dbcapi_isql.cpp

    This example shows how to write an ISQL-like application.

  • fetching_a_result_set.cpp

    This example shows how to fetch data from a result set.

  • fetching_multiple_from_sp.cpp

    This example shows how to fetch multiple result sets from a stored procedure.

  • preparing_statements.cpp

    This example shows how to prepare and execute a statement.

  • send_retrieve_full_blob.cpp

    This example shows how to insert and retrieve a blob in one chunk.

  • send_retrieve_part_blob.cpp

    This example shows how to insert a blob in chunks and how to retrieve it in chunks as well.