Early versions of DB2 did not provide any means in SQL syntax to connect to a database at execution time; instead you were expected to code calls to the appropriate SQL API routines. Previous versions of Micro Focus products included a SQLINIT or SQLINI2 module to perform the CONNECT function. These routines are no longer provided. Instead, the DB2 ECM will now generate the appropriate CONNECT statement, depending on the setting of the INIT option of the DB2 Compiler directive.
The INIT option has the additional option of ensuring that the database connection is correctly closed down even if the application is abnormally terminated, to avoid possible database corruption. If the application is abnormally terminated, all changes since the last COMMIT are rolled back. This database protection can be selected by specifying INIT=PROT on the DB2 Compiler directive.
The INIT option must only be set once for an application. SQL programs called by other SQL programs should not have the INIT option set. Alternatively, you can specify the INIT option for the first SQL program to be executed in a run unit. Compiling more than one module in an application with the INIT option may cause your program to terminate abnormally.
If you use DB2 LUW 7.2 with fixpack 8 or later, and if you specify the PASS directive option with the INIT directive option, INIT does not generate blank host variables for the user ID and password to connect to the database with, since this version of DB2 LUW generates an SQL error when these variables are passed with spaces or low values on a CONNECT. This is a change in the behavior of the INIT option. Programs compiled with these values will not work. We recommend that you do not use these directives and instead use an SQL CONNECT statement in your program.