DECLARE my_cursor CURSOR --定义游标,循环读取需要更新库存的ID--
FOR Select ProductId FROM [RetailInvoiceProduct] Where [RetailInvoiceId] = @RetailInvoiceId
OPEN my_cursor --打开游标
FETCH NEXT FROM my_cursor INTO @productId --把库存ID赋值给变量--
WHILE @@FETCH_STATUS = 0
BEGIN
Update [RetailInvoiceProduct] SET [isLock] = 1 Where [ProductId] = @productId
END
CLOSE my_cursor --关闭游标
FOR Select ProductId FROM [RetailInvoiceProduct] Where [RetailInvoiceId] = @RetailInvoiceId
OPEN my_cursor --打开游标
FETCH NEXT FROM my_cursor INTO @productId --把库存ID赋值给变量--
WHILE @@FETCH_STATUS = 0
BEGIN
Update [RetailInvoiceProduct] SET [isLock] = 1 Where [ProductId] = @productId
END
CLOSE my_cursor --关闭游标