Oracle PL/SQL - Subprograms, Packages and Triggers

Introduction

A PL/SQL subprogram is a named PL/SQL block that can be called repeatedly.

The subprogram can have parameters.

PL/SQL has two types of subprograms, procedures and functions. A function returns a result.

PL/SQL lets you invoke external programs written in other languages.

Packages

A package groups PL/SQL types, variables, constants, subprograms, cursors, and exceptions.

A package is compiled and stored in the database.

You can create your own packages and use the builtin packages.

Triggers

A trigger is a named PL/SQL unit stored in the database and run in response to an event.

You can specify the event, whether the trigger fires before or after the event.

For example, you can create a trigger that runs every time an INSERT statement affects the EMP table.