Was this helpful?
How the Synchronous Sample Code Works
The synchronous sample code consists of a number of sources files whose names begin with the prefix “apis”. Each source file demonstrates a single aspect of the OpenAPI interface and compiles into its own executable demo program.
OpenAPI functions are called synchronously: each OpenAPI function call is followed by a loop that calls IIapi_wait() repeatedly until the original OpenAPI call completes.
Note:  Database event processing is inherently asynchronous and is not demonstrated in the synchronous sample code. The asynchronous sample code provides an extensive example of database event handling using OpenAPI.
main() Function
The main() function at the beginning of the source file usually contains the specific aspect being demonstrated. OpenAPI function calls that support the demonstration, such as connection or transaction management, are at the end of the file. Sometimes, when the demonstration calls for multiple executions of an OpenAPI function, you can place the OpenAPI function call in its own function following main().
Error Checking
Typically, the sample programs do not perform error checking on the results of OpenAPI function calls. Error processing is demonstrated in one of the sample programs.
In general, these source files show:
How OpenAPI function parameters are established
The order in which OpenAPI functions are called to perform a specific action
How OpenAPI function output is processed
While the samples can be compiled and executed, the actual runtime actions performed provide little useful information.
How You Can Run a Program
Each sample program takes a single command line argument, which is the target database to run against. For example:
apisconn mydb
Source File Descriptions
The following list identifies the synchronous sample source files and the OpenAPI functionality they demonstrate.
apisinit.c
Demonstrates OpenAPI initialization, termination, and handling of environment handles.
apisdata.c
Demonstrates data conversion using IIapi_convertData() and IIapi_formatData().
apiserr.c
Demonstrates processing OpenAPI status results and error handling.
apisconn.c
Demonstrates establishing, terminating, and aborting connections.
apiscomm.c
Demonstrates committing transactions.
apisroll.c
Demonstrates rolling back transactions, setting savepoints, and rolling back to a savepoint.
apisauto.c
Demonstrates starting and ending autocommit transactions.
apis2ph1.c
Demonstrates distributed transactions (part 1): register transaction ID and prepare to commit.
apis2ph2.c
Demonstrates distributed transactions (part 2): connect to transaction, rollback, release transaction ID.
apisparm.c
Demonstrates handling of query parameters.
apissell.c
Demonstrates retrieving data using a select loop and canceling a query.
apisselc.c
Demonstrates retrieving data using a cursor.
apisscrl.c
Demonstrates retrieving data using a scrollable cursor.
apiscdel.c
Demonstrates deleting rows using a cursor.
apiscupd.c
Demonstrates updating rows using a cursor.
apisproc.c
Demonstrates executing database procedures.
apisprbr.c
Demonstrates executing database procedures with BYREF parameters.
apisprrp.c
Demonstrates executing row-producing database procedures.
apisprgt.c
Demonstrates executing database procedures with global temporary table parameters.
apiscopy.c
Demonstrates using COPY TABLE statement to transfer data between application and DBMS.
apisrept.c
Demonstrates defining and executing repeat statements.
apisblob.c
Demonstrates processing BLOB parameters and results.
apisname.c
Demonstrates accessing Name Server VNODE information.
Last modified date: 01/30/2023