关于DB2存储过程的几个小实例
================
CREATE PROCEDURE proc_with_variables (IN p_empno VARCHAR(6))
LANGUAGE SQL
SPECIFIC proc_with_vars -- applies to LUW and iSeries
-- WLM ENVIRONMENT <env> -- applies to zSeries
BEGIN
DECLARE v_empno VARCHAR(6);
DECLARE v_total, v_count INTEGER DEFAULT 0;
SELECT empno INTO v_empno FROM employee WHERE empno = p_empno ;
END
================
CREATE PROCEDURE set_variables ()
LANGUAGE SQL
SPECIFIC set_variables -- applies to LUW and iSeries
-- WLM ENVIRONMENT <env> -- applies to zSeries
BEGIN
DECLARE v_rcount INTEGER;
DECLARE v_max DECIMAL(9,2);
DECLARE v_adate,v_another DATE;
DECLARE v_total INTEGER DEFAULT 0; -- (1)
SET v_total = v_total + 1; -- (2)
SELECT MAX(salary) INTO v_max FROM employee; -- (3)
VALUES CURRENT DATE INTO v_adate; -- (4)
SELECT CURRENT DATE, CURRENT DATE
INTO v_adate, v_another
FROM SYSIBM.SYSDUMMY1; -- (5)
END
CREATE PROCEDURE registersample ( OUT p_start TIMESTAMP
, OUT p_end TIMESTAMP
, OUT p_c1 TIMESTAMP
, OUT p_c2 TIME
&n