Characteristics of thread-safe ESQL/C code
The thread-safe code
has the following characteristics that are different from non-thread-safe
code:
- The thread-safe code does not define any static data structures.
For example, allocates sqlda structures dynamically and binds host variables to these sqlda structures at run time. For more information about sqlda structures to perform dynamic SQL, see Working with the database server.
- The thread-safe code declares cursor blocks dynamically instead of declaring them statically.
- The thread-safe code uses macro definitions for status variables
(SQLCODE, SQLSTATE, and the sqlca structure).
For more information, see Define thread-safe variables (UNIX).
Because of the preceding differences, the thread-safe C source file (.c) that the preprocessor generates is different from the non-threaded C source file. Therefore, you cannot link applications that have been compiled with the -thread option with applications that have not already been compiled with -thread. To link such applications, you must compile both applications with the -thread option.