为什么存储过程会在重复记录中插入此SP? 但它只是从100个案件中发生了5-6例。 此SP同时插入重复记录,其类似2-4记录。 如何避免这个问题? 我使用ASP.Net MVC代码,并使用AJAX进行POST。 我有这样的存储过程
DECLARE
@PromotionID nvarchar(40)='',
@LoginName nvarchar(200),
@PromotionApplyStatusID int=0,
@PromotionCode nvarchar(40)='',
@ClaimTimestamps datetime2= null,
@RemarkText nvarchar(MAX)='',
@BetIDText nvarchar(MAX)='',
@TransIDText nvarchar(MAX)='',
@ShippingAddressText nvarchar(MAX)='',
@PrizeAmount decimal=0,
@TurnOver int=0,
@Currency nvarchar(40)='',
@result int=0,
@AccountID int=0
SET @AccountID = (SELECT AccountID FROM MemberAccount WHERE MemberID = (SELECT MemberID FROM Member WHERE WebsiteID=2 AND Member.MemberName=@LoginName))
IF EXISTS (SELECT * FROM SystemPromotionDetail WHERE PromotionID=@PromotionID AND AccountID=@AccountID AND PromotionApplyStatusID=0)
BEGIN
DELETE SystemPromotionDetail
WHERE PromotionID=@PromotionID AND AccountID=@AccountID AND PromotionApplyStatusID=0
END
IF NOT EXISTS (SELECT * FROM SystemPromotionDetail WHERE PromotionID=@PromotionID AND AccountID=@AccountID AND PromotionApplyStatusID=0)
BEGIN
INSERT INTO SystemPromotionDetail
(
PromotionID,
AccountID,
PromotionApplyStatusID,
PromotionCode,
ClaimTimestamps,
RemarkText,
BetIDText,
TransIDText,
ShippingAddressText,
PrizeAmount,
TurnOver,
Currency
)
VALUES
(
@PromotionID ,
@AccountID,
@PromotionApplyStatusID,
@PromotionCode,
@ClaimTimestamps,
@RemarkText,
@BetIDText,
@TransIDText,
@ShippingAddressText,
@PrizeAmount,
@TurnOver,
@Currency
)
END