1.执行存储过程
CALL productpricing(@pricelow,@pricehigh,@priceaverage);
2.创建存储过程
CREATE PROCEDURE productpricing()
BEGIN
SELECT Avg(prod_price) AS priceaverage
FROM products;
END;
使用:
CALL productpricing();
3.删除存储过程
DROP PROCEDURE productpricing;
4.使用参数
CREATE PROCEDURE odertotal(IN onumber INT,OUT ototal DECIMAL(8,2))
BEGIN
SELECT Sum(item_price*quantity)
FROM orderitems
WHERE order_num=onumber
INTO ototal
END;
调用:
CALL ordertotal(20005,@total);
显示
SELECT @total;
5.检查存储过程
SHOW PROCEDURE STATUS