Was this helpful?
How Query Statements Work
An application invokes query statements by calling the IIapi_query() function and providing the statement type and statement text in input parameters. Normally, the application obtains the results of the query by calling the IIapi_getQueryInfo() function and closes the statement by calling the IIapi_close() function.
Note:  Most of the information in this guide pertains to connecting to and operating on a DBMS, but you can work with the Name Server also. The term server is used generically, and query statement is used generically for either an SQL statement or Name Server query statement.
Data exchange between the application and a server requires two sets of information: data descriptors and data values. Query parameters are passed in calls to the IIapi_setDescriptor() and IIapi_putParms() functions. Result data returned by query statements is retrieved by calls to the IIapi_getDescriptor() and IIapi_getColumns() functions.
Typical Flow of Operations for SQL and Name Server Query Statement Processing
 
Depending on the query operation, the application may call additional OpenAPI functions. For statements that return data (the SQL select statement, Name Server show statement, database procedures with BYREF, INOUT, or OUT parameters, and row-returning database procedure), and for the SQL copy statement, the order in which an application invokes OpenAPI functions is shown in the figure that follows.
Order of Invoking OpenAPI Functions
The left side of the diagram shows the sequence of functions for statements that return data. The right side shows the sequence of functions for copying data from a database table to the program (copy into) and copying data from the program into a database table (copy from).
How Query Statements Are Canceled
An application can cancel a query statement started with IIapi_query() before the statement is fully executed. To cancel a query statement, the application issues IIapi_cancel(), specifying the statement handle returned by IIapi_query(). IIapi_cancel() can be called anytime after IIapi_query() has returned with a status of “success.” If the query has already been completed, an error is returned to the application stating so.
Last modified date: 01/30/2023