Implementing Db2 stored procedures
A stored procedure is executable code that can be called by other programs. You might choose to use stored procedures for code that is used repeatedly. Other benefits of using stored procedures include reducing network traffic, returning result sets to an application, or allowing access to data without granting the privileges to the applications.
You can create your own stored procedures to perform whatever functions you need, Db2 also provides a set of stored procedures that perform some common functions that you might find useful. These stored procedures are called Db2-supplied stored procedures.
Before you begin
You must complete some configuration tasks for the Db2 environment before you can use any of the following types of procedures:
- External stored procedures
- Native SQL procedures that satisfy any of the following conditions:
- Calls at least one external stored procedure, external SQL procedure, or user-defined function.
- Defined with ALLOW DEBUG MODE or DISALLOW DEBUG MODE.
- External SQL procedures (deprecated)
- Db2-supplied stored procedures
For instructions, see Installation step 21: Configure Db2 for running stored procedures and user-defined functions or Migration step 23: Configure Db2 for running stored procedures and user-defined functions (optional).
Procedure
To implement stored procedures in Db2:
What to do next
- Alter the stored
procedure options or body. Restriction: For external SQL procedures, you can alter only the procedure description. You cannot alter the body.
- Debug the stored procedure.
- Improve the performance of a stored procedure.
- Migrate external SQL procedures to native SQL procedures.
- Migrate stored procedures from test to production.