CREATE PROCEDURE SP_GET_ITEM_COUNT (IN ARG_ITEM_ID INT,
OUT SP_RESULT INT,
OUT SQLCODE_OUT INT )
LANGUAGE SQL
P1: BEGIN
-- Declare variables
DECLARE SQLCODE INT DEFAULT 0;
-- Declare handler
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET SQLCODE_OUT = SQLCODE;
SELECT COUNT(*) INTO SP_RESULT
FROM ORDER_ITEMS
WHERE ITEM_ID=ARG_ITEM_ID;
SET SQLCODE_OUT = SQLCODE;
END P1
|