| < Day Day Up > |
|
With Oracle you can define initialization in PL/SQL packages, which is executed only one time when starting a new database session. Example 5-25 shows the initialization within an Oracle package.
Example 5-25: Oracle package with initialization
CREATE OR REPLACE PACKAGE BODY pkg_init_v1 AS -- function / procedure definition -- ... -- Body initialization BEGIN -- ... END pkg_init_v1;
In DB2 UDB, each SQL PL block is a function or procedure beginning with CREATE FUNCTION or CREATE PROCEDURE. MTK is able to convert the Example 5-25 if you define a procedure with the initialization commands.
Example 5-26 shows an alternative of Example 5-25 with the same behavior. In the initialization, part is now only the call of the procedure init, within init is the source of the initialization.
Example 5-26: Oracle package with initialization as procedure
CREATE OR REPLACE PACKAGE BODY pkg_init_v2 AS -- function / procedure definition -- ... -- initialization procedure PROCEDURE init IS BEGIN -- ... END; -- Body initialization BEGIN init; END pkg_init_v2;
Within your application, you have to add the call of the procedure init to perform the initialization every time you connect to the database.
| < Day Day Up > |
|