在以下代码中,我在每个嵌套的IF和ELSE语句上都会出现“语法错误”错误。。。怎么了?
ALTER PROCEDURE [WTFAULT].[usp_WTFault_GetPartFaultStatus]
(
@linxPartId int = -1,
@faultStatus varchar(10) output
)
AS
BEGIN
DECLARE @NbFaultsInParts int,
@NbPartsReturned int
SET @NbPartsReturned = (SELECT COUNT(*) FROM WTFAULT.PART, WTFAULT.FAULT WHERE WTFAULT.PART.FAULT_COID = WTFAULT.FAULT.COID
AND WTFAULT.PART.LINX_PARTID = @linxPartId AND WTFAULT.FAULT.MATURITY = ALLOCATED )
IF @NbPartsReturned > 0 BEGIN
SET @faultStatus = ALLOCATED
END
ELSE BEGIN
SET @NbPartsReturned = (SELECT COUNT(*) FROM WTFAULT.PART, WTFAULT.FAULT WHERE WTFAULT.PART.FAULT_COID = WTFAULT.FAULT.COID
AND WTFAULT.PART.LINX_PARTID = @linxPartId AND WTFAULT.FAULT.MATURITY = DRAFT )
IF @NbPartsReturned > 0 BEGIN
SET @faultStatus = DRAFT
END
ELSE BEGIN
SET @NbPartsReturned = (SELECT COUNT(*) FROM WTFAULT.PART, WTFAULT.FAULT WHERE WTFAULT.PART.FAULT_COID = WTFAULT.FAULT.COID
AND WTFAULT.PART.LINX_PARTID = @linxPartId AND WTFAULT.FAULT.MATURITY = CLOSED )
IF @NbPartsReturned > 0 BEGIN
SET @faultStatus = CLOSED
END
ELSE BEGIN
SET @faultStatus =
END
END
END
END
GO