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.
The API is built as a dynamic link library (DLL) (dbcapi.dll) on Microsoft Windows systems and as a shared object (libdbcapi.so) 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.
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.
Examples that show how to use the C API can be found in the sdk\dbcapi\examples subdirectory of your database software installation.
This is an example of how to create and use callbacks.
This is an example of how to create a connection object and use it to connect to a database.
This example shows how to write an ISQL-like application.
This example shows how to fetch data from a result set.
This example shows how to fetch multiple result sets from a stored procedure.
This example shows how to prepare and execute a statement.
This example shows how to insert and retrieve a blob in one chunk.
This example shows how to insert a blob in chunks and how to retrieve it in chunks as well.