创建存储过程
create procedure productpricing()
begin
select avg(prod_price) as priceaverage
from products;
end;
执行存储过程
call productpricing();
删除存储过程
drop procedure productpricing;
使用参数
create procedure productpricing(
out pl decimal(8,2),
out ph decimal(8,2).
out pa decimal(8,2)
)
begin
select min(prod_price) into pl from products;
select max(prod_price) into ph from products;
select avg(prod_price) into pa from products;
end;
create procedure ordertotal(
in onumber int,
out ototal decimal(8,2)
)
begin
select sum(item_price*quantity)
from orderitems
where order_num = onumber
into ototal;
end;
检查存储过程
show create procedure ordertotal;
本文介绍了如何在数据库中创建存储过程,包括基本的`productpricing`过程,用于计算价格平均值,以及带参数的`ordertotal`过程,用于计算订单总额。还展示了如何执行、删除存储过程及检查其创建详情。
1834

被折叠的 条评论
为什么被折叠?



