Creating DB2 stored procedures
You can use the New Stored Procedure wizard to create DB2 stored procedures in SQL or Java.
Prerequisites: Before you can create a routine, complete the following prerequisite steps:
- Create or import a DB2 database definition in your Data Definition view. The definition must include at least one schema and table. You can either create a database definition in the Data Definition view, or you can connect to a database using the New Database Connection wizard in the Database Explorer view and copy the definitions to a folder in the Data Definition view.
- Enable workbench capabilities for database development. To enable these capabilities:
- Click Window > Preferences from the main menu.
- Click Workbench > Capabilities, and select the Database Developer check box to enable all database capabilities.
Using the New Stored Procedure wizard, you name the stored procedure, define the structure and SQL statement, and specify the parameters and additional options. You can also customize the generated source code by specifying files that contain code fragments. You can specify the following types of code fragments:
- For an SQL stored procedure: header, variables declaration, exception handlers, and statements that precede the END statement
- For a Java stored procedure: header, import statements, class variable declarations, and methods
To create a stored procedure using the wizard:
- Switch to the Data perspective.
- In the Data Definition view, right-click the Stored Procedures folder under a database definition, and click New > SQL Stored Procedure or New > Java Stored Procedure. The New Stored Procedure wizard opens.
- Complete the steps of the wizard.
The wizard creates the stored procedure and adds to your database definition in the Stored Procedures folder.
Parent topic
DB2 stored procedures
Related concepts
Overview of DB2 stored procedures tasks
Tips for developing DB2 stored procedures
Related tasks
Preparing to debug a DB2 SQL stored procedure
Related reference
Stored procedure task restrictions
Stored procedure and user-defined function support by DB2 Universal Database server type