Creating a stored procedure

A stored procedure is executable code that can be called by other programs. The process for creating one depends on the type of procedure.

Before you begin

Before you can use the following types of stored procedures, you must configure your DB2® for z/OS® subsystem for running stored procedures during installation or configure your DB2 for z/OS subsystem for running stored procedures during migration.

  • External stored procedures
  • External SQL procedures
  • Native SQL procedures that satisfy at least one of the following conditions:
    • The native SQL procedure calls at least one external stored procedure, external SQL procedure, or user-defined function.
    • The native SQL procedure is defined with ALLOW DEBUG MODE or DISALLOW DEBUG MODE.
  • DB2-supplied stored procedures

About this task

You can create one of the following types of stored procedures:
External stored procedures
A procedure that is written in a host language.
External SQL procedures
A procedure whose body is written entirely in SQL, but is created, implemented, and executed like other external stored procedures.
Native SQL procedures
A procedure with a procedural body that is written entirely in SQL and is created by issuing a single SQL statement, CREATE PROCEDURE. Native SQL procedures do not have an associated external application program.

Procedure

To create a stored procedure, perform one of the following actions: