创建存储过程:
create procedure dbo.order_account
@@merchantId varchar(30),
@@totalAmount numeric(15,3)=0 output
AS
DECLARE @tempAmount numeric(15,3)
select @tempAmount = sum(fd_tx_money) from tb_order where fd_merchant_id=@@merchantId
set @@totalAmount = @tempAmount
删除存储过程:
drop proc order_account
create procedure dbo.order_account
@@merchantId varchar(30),
@@totalAmount numeric(15,3)=0 output
AS
DECLARE @tempAmount numeric(15,3)
select @tempAmount = sum(fd_tx_money) from tb_order where fd_merchant_id=@@merchantId
set @@totalAmount = @tempAmount
删除存储过程:
drop proc order_account
本文介绍了一个简单的存储过程创建和删除的方法。存储过程接受商户ID作为参数,并返回该商户所有订单的总金额。首先定义了存储过程并设置了默认输出值,接着通过查询订单表计算总金额并将其设置为输出值。

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



