Context threaded optimization
allows developers to specify the runtime context that is used for a set of statements. A runtime context holds all the thread-specific data that must maintain including connections and their current states, cursors, and their current states.
This feature allows programmers to improve the performance of their MESQL/C applications. By using the SQLCONTEXT definitions and directives, the number of thread-specific data block lookups is reduced.
SQLCONTEXT context_var;
PARAMETER SQLCONTEXT param_context_var;
BEGIN SQLCONTEXT OPTIMIZATION;
END SQLCONTEXT OPTIMIZATION;
The SQLCONTEXT definition and statements are only recognized when the esql-thread option is used. If the -thread option is not specified, the statements are ignored.
The use of the SQLCONTEXT statements causes the ESQL/C preprocessor to generate code in the .c file that differs from the generated code when no SQLCONTEXT statements are present.
SQLCONTEXT context_var;
PARAMETER SQLCONTEXT param_context_var;
BEGIN SQLCONTEXT OPTIMIZATION;
...
END SQLCONTEXT OPTIMIZATION;
The END SQLCONTEXT directive appears before the end of the scope of the SQLTCONTEXT definition currently used, or compile-time errors occur for “undefined symbol sql_context_var.”