Although embedded SQL stored procedures provide the most advantages, application developers who have existing DB2 CLI applications may wish to move components of the application to run on the server. In order to minimize the required changes to the code and logic of the application, these components can be implemented as stored procedures, written using DB2 CLI.
Since all the internal information related to a DB2 CLI connection is referenced by the connection handle and since a stored procedure runs under the same connection and transaction as the client application, it is necessary that a stored procedure written using DB2 CLI make a null SQLConnect() call to associate a connection handle with the underlying connection of the client application. A null SQLConnect() is where the ServerName, UserName, and Authentication argument pointers are all set to NULL and their respective length arguments all set to 0. Of course, in order that an SQLConnect() call can be made at all, the environment and connection handles must already be allocated.
Note: | Stored procedures written using Embedded SQL must be precompiled with the DATETIME ISO option in order for DB2 CLI to deal with date-time values correctly. |