Writing a Db2 for i CLI application

A Db2® for i CLI application consists of a set of tasks; each task consists of a set of discrete steps. Other tasks might occur throughout the application when it runs. The application calls one or more Db2 for i CLI functions to carry out each of these tasks.

Every Db2 for i CLI application contains the three main tasks that are shown in the following figure. If the functions are not called in the sequence that is shown in the figure, an error results.

Figure 1. Conceptual view of a Db2 for i CLI application
Conceptual View of a Db2 for i CLI Application

The initialization task allocates and initializes resources in preparation for the main Transaction Processing task.

The transaction processing task, the main task of the application, passes queries and modifications to the SQL to Db2 for i CLI.

The termination task frees allocated resources. The resources generally consist of data areas that are identified by unique handles. After freeing the resources, other tasks can use these handles.

In addition to the three central tasks that control a Db2 for i CLI application, there are numerous general tasks, such as diagnostic message handlers, throughout an application.

See Categories of Db2 for i CLI functions for an overview of how the CLI functions fit into these key task areas.