Application Development Guide


Writing SQL Procedures

  • Comparison of SQL Procedures and External Procedures
  • Valid SQL Procedure Body Statements
  • Issuing CREATE PROCEDURE Statements
  • Handling Conditions in SQL Procedures
  • Declaring Condition Handlers
  • SIGNAL and RESIGNAL Statements
  • SQLCODE and SQLSTATE Variables in SQL Procedures
  • Using Dynamic SQL in SQL Procedures
  • Nested SQL Procedures
  • Passing Parameters Between Nested SQL Procedures
  • Returning Result Sets From Nested SQL Procedures
  • Restrictions on Nested SQL Procedures
  • Returning Result Sets From SQL Procedures
  • Returning Result Sets to Caller or Client
  • Returning Result Sets to the Client
  • Returning Result Sets to the Caller
  • Receiving Result Sets as a Caller
  • Debugging SQL Procedures
  • Displaying Error Messages for SQL Procedures
  • Debugging SQL Procedures Using Intermediate Files
  • Examples of SQL Procedures
  • An SQL procedure is a stored procedure in which the procedural logic is contained in a CREATE PROCEDURE statement. The part of the CREATE PROCEDURE statement that contains the code is called the procedure body.

    To create an SQL procedure, simply issue the CREATE PROCEDURE statement like any other DDL statement. You can also use the IBM DB2 Stored Procedure Builder to help you define the stored procedure to DB2, specify the source statements for the SQL procedure, and prepare the procedure for execution. For more information on the IBM DB2 Stored Procedure Builder, see IBM DB2 Stored Procedure Builder.

    This chapter discusses how to write a CREATE PROCEDURE statement that includes a procedure body. For more information on the syntax of the CREATE PROCEDURE statement and the procedure body, refer to the SQL Reference. For more information on using the IBM DB2 Stored Procedure Builder to create SQL procedures, see IBM DB2 Stored Procedure Builder.


    [ Top of Page | Previous Page | Next Page ]