Query Parameters
OpenAPI does not support host variables, as does embedded SQL. There are several mechanisms by which an application can handle queries for which the parameter values are not known until runtime.
First, the application can use C library string formatting routines, such as sprintf(), to build the SQL query text at runtime. Parameter values are formatted as literals in the query text prior to query execution.
Second, the application can use dynamic SQL and provide the parameter values as parameters to the query when the statement is executed or a cursor is opened. (Dynamic SQL is not supported by the Name Server.)
A third method, which uses parameter markers but does not require the statement to be prepared, is also available. This method is the same mechanism used by embedded SQL to handle host variables. It is also the only method that handles runtime parameter values for repeat queries. Since this mechanism is usually hidden to applications, it is not described further here.
Note: Parameter strings in queries should be sent as varchar type, rather than chars type, due to the pattern matching method used by the DBMS Server.
More information:
Last modified date: 08/14/2024