我已经编写了这个存储过程并且它执行但它不会更新客户。问题是:创建一个名为 prc_cus_balance_update 的过程,它将发票编号作为参数并更新客户余额。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE PRC_CUS_BALANCE_UPDATE3
@INV_NUMBER INT
AS
BEGIN
DECLARE @CUS_CODE INT
SELECT @CUS_CODE=CUS_CODE
FROM INVOICE
WHERE @INV_NUMBER=INV_NUMBER
UPDATE CUSTOMER
SET CUS_BALANCE=CUS_BALANCE +
(SELECT INV_TOTAL FROM INVOICE WHERE @INV_NUMBER=INV_NUMBER)
WHERE @CUS_CODE=CUS_CODE
END
GO