所以我正在为一个网页编写一个存储过程,它将从网页中提取 3 个参数,然后根据其他 2 个的值存储一个。
ALTER PROCEDURE [dbo].[PMRAssignDate]
@PMRID int,
@Department varchar(255),
@AssignDate date
AS
BEGIN
IF EXISTS(SELECT * FROM [ProductInformation].[dbo].[PMRInformation] WHERE PMRID = @PMRID)
Begin
IF @Department='Engineering'
Begin
Insert INTO
[dbo].[PMRInformation]
(EngineeringApprovalDate)
Values
(@AssignDate)
End
Else IF (@Department='Operations')
Begin
Insert INTO
[dbo].[PMRInformation]
(OperationsApprovalDate)
Values
(@AssignDate)
End
Else IF (@Department='AME')
Begin
Insert INTO
[dbo].[PMRInformation]
(AMEApprovalDate)
Values
(@AssignDate)
End
Else IF @Department='Finance'
Begin
Insert INTO
[dbo].[PMRInformation]
(FinanceApprovalDate)
Values
(@AssignDate)
End
Else IF @Department='Marketing'
Begin
Insert INTO
[dbo].[PMRInformation]
(MarketingApprovalDate)
Values
(@AssignDate)
End
Else IF @Department='Tester'
Begin
Insert INTO
[dbo].[PMRInformation]
(EngineeringApprovalDate, MarketingApprovalDate, AMEApprovalDate, FinanceApprovalDate, OperationsApprovalDate)
Values
(@AssignDate,@AssignDate,@AssignDate,@AssignDate,@AssignDate)
End
End End
所以这个存储过程必须找到 PMRID 等于从网页发送的@PMRID 的行。然后它必须使用@Department 变量来确定将批准日期@AssignDate 存储到哪个部门。到目前为止,程序运行,但它没有将日期存储在正确的行中。它将创建一个新行并将批准日期插入该新行。能否请你帮忙。谢谢!