Creating native SQL procedures

A native SQL procedure is a procedure whose body is written entirely in SQL and is created by issuing a single SQL statement, CREATE PROCEDURE.

Before you begin

Before you create a native SQL procedure, Configure Db2 for running stored procedures and user-defined functions during installation or Configure Db2 for running stored procedures and user-defined functions during migration if the native SQL procedure satisfies 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. If you specify DISABLE DEBUG MODE, you do not need to set up the stored procedure environment.

About this task

A native SQL procedure is a procedure whose body is written entirely in SQL. The body is written in the SQL procedural language (SQL PL). A native SQL procedure is created by issuing a single SQL statement, CREATE PROCEDURE. Native SQL procedures do not require any other program preparation, such as precompiling, compiling, or link-editing source code. Native SQL procedures are executed as SQL statements that are bound in a Db2 package. Native SQL procedures do not have an associated external application program. Native SQL procedures are more fully supported, easier to maintain, and typically perform better than external SQL procedures, which are deprecated.

Procedure

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

What to do next

After you create a native SQL procedure, you can create additional versions of the procedure as needed. For more information, see Creating new versions of native SQL procedures.