Procedure Declaration and Definition

A procedure is a subprogram that performs a specific action.

You must declare and define a procedure before invoking it. You can either declare and define it at the same time, or you can declare it first and then define it later in the same block or subprogram.

Note:

This topic applies to procedures that you declare and define inside a PL/SQL block or package, which are different from standalone stored procedures that you create with the CREATE PROCEDURE Statement.

Syntax

procedure_declaration ::=

procedure_declaration
Description of the illustration procedure_declaration.gif

procedure_heading ::=

procedure_heading
Description of the illustration procedure_heading.gif

(parameter_declaration ::=)

procedure_definition ::=

procedure_definition
Description of the illustration procedure_definition.gif

(body ::=, declare_section ::=)

Keyword and Parameter Descriptions

body

The required executable part of the procedure and, optionally, the exception-handling part of the procedure.

declare_section

The optional declarative part of the procedure. Declarations are local to the procedure, can be referenced in body, and cease to exist when the procedure completes execution.

procedure_declaration

Declares a procedure, but does not define it. The definition must appear later in the same block or subprogram as the declaration.

A procedure declaration is also called a procedure specification, or procedure spec.

procedure_definition

Either defines a procedure that was declared earlier in the same block or subprogram, or declares and defines a procedure.

procedure_name

The name that you give to the procedure that you are declaring or defining.

Examples

Related Topics