4-10. Writing Initialization Code for a Package

Problem

You want to execute some code each time a particular PL/SQL package is instantiated in a session.

Solution

Create an initialization block for the package in question. By doing so, you will have the ability to execute code each time the package is initialized. The following example shows the same package that was constructed in Recipe 4-7. However, this time the package contains an initialization block.

CREATE OR REPLACE PACKAGE BODY process_employee_time IS   PROCEDURE grant_raises (pct_increase IN NUMBER,                           upper_bound IN NUMBER) as   CURSOR emp_cur is   SELECT employee_id, first_name, last_name   FROM employees;   BEGIN   -- loop through each record in the employees ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.