Tutorial 2: Debugging a stored procedure

This tutorial describes a sample session for debugging a stored procedure. It is a continuation of “Tutorial 1: Getting started with the debugger”.

In this tutorial, you call the stored procedure sp_customer_products, which is part of the sample database.

The sp_customer_products procedure executes the following query against the sample database:

CREATE PROCEDURE dba.sp_customer_products( 
    INOUT customer_id INTEGER )
RESULT(id integer,quantity_ordered integer)
BEGIN
  SELECT product.id,sum(sales_order_items.quantity)
  FROM product,sales_order_items,sales_order
  WHERE sales_order.cust_id = customer_id 
  AND sales_order.id = sales_order_items.id 
  AND sales_order_items.prod_id = product.id
  GROUP BY product.id
END

It takes a customer ID as input, and returns as a result set a list of product IDs and the number ordered by that customer.