INIT

Generates a CONNECT statement and/or exit handling code to ensure rollback to the last commit point in the case of an abnormal termination.
Note: INIT, INIT=S and INIT=X are deprecated, and provided for backward compatibility only.
Important: We strongly recommend that you use EXEC SQL CONNECT statements in your application instead of INIT, INIT=S or INIT=X.

Syntax:

INIT[={[PROT|P] | S | X}]
NOINIT

Parameters:

INIT Generates a CONNECT statement in shared mode, and also generates exit handling code
INIT=S
INIT=X Generates a CONNECT statement in exclusive mode, and also generates exit handling code
INIT=PROT Generates exit handling code only.
INIT=P
NOINIT No code generation whatsoever.

Properties:

Default: NOINIT

Dependency:

  • If your INIT call generates a connection, you can use it with the DB2 PASS compiler directive option.

Comments:

  • For the following reasons, we strongly recommend that you consider placing an EXEC SQL CONNECT statement into your code instead of using INIT, INIT=S or INIT=X :
    • Because INIT actually stores user credentials in your code, its use can raise security concerns.
    • If IBM were to change the underlying APIs used to implement a database connection, this could cause compatibility problems when using INIT.
  • Set the INIT directive, regardless of the parameter options, only once for each application. Do not set INIT for SQL programs called by other SQL programs. Instead, specify the INIT option for the first SQL program executed in a run unit. Compiling more than one module in an application with the INIT option could cause your program to terminate abnormally.
  • INIT is ignored when used within an OO program.