Previous Topic Next topic Print topic


INIT

When set without parameters, the preprocessor automatically generates code to make the connection to the database. When set with the PROT parameter, protects the database when an application terminates abnormally.
Note: The INIT directive (without PROT) is deprecated, and provided for backward compatibility only. We strongly recommend that you use EXEC SQL CONNECT statements in your application instead.

Syntax:

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

Parameters:

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

Properties:

Default: NOINIT

Dependencies:

If your INIT call generates a connection, you can use it with the DB and PASS SQL compiler directive options.

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 :
    • INIT actually stores user credentials in your code, so its use can raise security concerns.
    • If the DBMS vendor were to change the underlying APIs used to implement a database connection, this could cause compatibility problems when using INIT.
  • Set the INIT directive, with or without PROT, 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.
Previous Topic Next topic Print topic