Create, test, and deploy a Db2 SQL stored procedure

This tutorial teaches you how to create, test, and deploy a Db2® SQL stored procedure, which can improve application performance by reducing database access traffic. For each SQL statement, a database manager application must initiate a separate communication with Db2. Database performance is improved because the stored procedure runs the SQL statement on the server rather than on the client. Db2 stored procedures also help to centralize business logic by immediately changing a stored procedure available to all client applications.

An SQL stored procedure is a stored procedure whose source code is part of the CREATE PROCEDURE statement or the stored procedure body.

Learning objectives

These exercises teach you how to:
  • Set up the workbench environment for stored procedure development
  • Connect to the Db2 SAMPLE database and create a data development project to work with the database
  • Create an SQL stored procedure
  • Deploy, debug, and run the stored procedure from the workbench
  • Export and deploy the stored procedure from the file system
This tutorial takes approximately 60 minutes to finish. If you explore other concepts that are related to this tutorial, it can take longer to complete.

Skill level

Advanced

Audience

Database developers

System requirements

  • You must install and configure the SAMPLE database that is included with Db2 for Linux®, UNIX, and Windows. For more information about the SAMPLE database, see the Db2 documentation and First Steps.
  • To follow the steps in this tutorial for debugging a stored procedure, you must have Db2 for Linux, UNIX, and Windows Version 9.1 or later.

Prerequisites

To complete this tutorial, you must be familiar with the following concepts:
  • Database development
  • SQL and SQL stored procedure development