Reputation: 11
My IF..ELSE
block fails at BEGIN
. I can understand how my expression is not boolean in nature, but what is causing this failure?
IF (SUBSTRING(@PARIDIN,1,1) = 'P'
BEGIN
SET @PARIDTEMP = SUBSTRING(LTRIM(RTRIM(@PARIDIN)),2,6))
END
BEGIN
ELSE SET @PARIDTEMP = @PARIDIN
END
Upvotes: 1
Views: 1692
Reputation: 8475
You have an extra set of parentheses in a weird place.:
IF SUBSTRING(@PARIDIN,1,1) = 'P' -- one at the beginning of this line.
BEGIN
SET @PARIDTEMP = SUBSTRING(LTRIM(RTRIM(@PARIDIN)),2,6) -- one at the end of this line.
END
ELSE
BEGIN
SET @PARIDTEMP = @PARIDIN
END
Upvotes: 2
Reputation: 33571
Taking everybody else's suggestion of fixing the condition I am surprised nobody mentioned the very strange BEGIN END blocks. They don't make sense and not sure they would even work. Since you have only a single statement for each it makes more sense to remove them.
IF (SUBSTRING(@PARIDIN,1,1) = 'P')
SET @PARIDTEMP = SUBSTRING(LTRIM(RTRIM(@PARIDIN)),2,6))
ELSE
SET @PARIDTEMP = @PARIDIN
Upvotes: 0
Reputation: 15175
You are not closing the expression being evaluated.
Change
IF (SUBSTRING(@PARIDIN,1,1) = 'P'
To
IF (SUBSTRING(@PARIDIN,1,1) = 'P')
Upvotes: 1