我正在编写一个存储过程,例如 in update 语句,但我混淆了如何应用这种类型的东西?
我的存储过程是:
ALTER PROCEDURE [dbo].[Payment_SP]
@reciptId varchar(50)=null,
@balPay float=null,
@payDone float=null,
@payDate datetime=null,
@fullfillId_FK varchar(50)=null,
@clintId_FK int=null,
@status varchar(50)=null,
@operation int,
@fullfillId varchar(50)=null
AS
BEGIN
if @operation = 3
BEGIN
UPDATE Recipt
SET balPay = @balPay
WHERE reciptId = @reciptId
if @@rowcount = 0
insert into Recipt(reciptId, balPay, payDone, payDate, fullfillId_FK, clintId_FK)
values(@reciptId, @balPay, @payDone, @payDate, @fullfillId_FK, @clintId_FK)
update Item_Full
set totCost = (select balPay from Recipt)
where fullfillId = @reciptId
if @balPay='0'
BEGIN
update Item_Order
set status = 'CLOSE'
where status = 'FULLFILL'
or status = 'RUNNING'
and orderId = @reciptId
END
ELSE
BEGIN
update Item_Order
set status = 'RUNING'
where status = 'FULLFILL'
and orderId = @reciptId
END
END
END
在这里,我使用了大量的表格和列。Recipt
但是如果余额支付(@balPay = 0) ,那么我想在表中执行此操作,然后状态 = 关闭,否则如果有任何余额 > 0,那么状态 = 运行
但每次我获得状态都是RUNING
在付款完成后。这意味着只有条件语句的 else 部分正在执行,而不是 if 部分
if 语句中应该有什么条件
谢谢