EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Page 612

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
RETURN statement
594
The following procedure uses the RETURN statement to avoid
executing a complex query if it is meaningless:
CREATE PROCEDURE customer_products
( in customer_id integer DEFAULT NULL)
RESULT ( id integer, quantity_ordered integer )
BEGIN
IF customer_id NOT IN (SELECT id FROM customer)
OR customer_id IS NULL THEN
RETURN
ELSE
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 IF
END

Table of Contents

Related product manuals