Starting DB2® for i CLI in SQL server mode
There are two ways to place a job into SQL server mode.
- The
most used method is using the call level interface (CLI) function, SQLSetEnvAttr().
The SQL server mode is best suited to CLI applications because they
already use the concept of multiple connections handles. Set this
mode immediately after allocating the CLI environment. If server mode
is not set immediately following the allocation of the CLI environment
then the mode will not be changed to server mode, and SQL continues
to run inline.
EXAMPLE.
.
SQLAllocEnv(&henv);
long attr;
attr = SQL_TRUE
SQLSetEnvAttr(henv,SQL_ATTR_SERVER_MODE,&attr,0);
SQLAllocConnect(henv,&hdbc);
.
. - The second way to set the server mode is using the Change Job (QWTCHGJB) API.
As soon as SQL server mode has been set, all SQL connections and SQL statements run in server mode. There is no switching back and forth. The job, when in server mode, cannot start commitment control, and cannot use Interactive SQL.