I get “incorrect syntax” error msg’s with the following.
In actual use, if one of the following (AW, PR, TS, SW, RW or GS) is not entered as the StepCode, then error msg. For brevity's sake, not all have been listed below for Case selection example.
Thanks,
Bill
In actual use, if one of the following (AW, PR, TS, SW, RW or GS) is not entered as the StepCode, then error msg. For brevity's sake, not all have been listed below for Case selection example.
Code:
--Beginning the use of CASE statements
Begin
Select StepCode =
case StepCode
when 'PR'
then
--begin --"incorrect syntax near IF"
IF @PrevailingWage is null or @PrevailingWage = 0
begin --must have a prevailingWage value
set @Message = 'Prevailing Wage Required'
set @Continue = 0
end
IF @Standard is null or @Standard = 0
begin --must have a Standard value
set @Message = 'Standard Required'
set @Continue = 0
end
--end
WHEN 'TS' --"incorrect syntax near WHEN"
then
IF @PrevailingWage is null or @PrevailingWage = 0
begin --must have a prevailingWage value
set @Message = 'Prevailing Wage Required'
set @Continue = 0
end
--Can Not Use Guaranteed Step Wage With This Step Code
if @GuaranteedStepWage is NOT null or @GuaranteedStepWage <> 0
begin
set @Message = 'Can Not Use Guaranteed Step Wage With This Step Code'
set @Continue = 0
end
--cannot use standard with this step code
if @Standard is NOT null or @Standard <> 0
begin
set @Message = 'Cannot Use Standard With This Step Code'
set @Continue = 0
end
--end
when 'AW' --"incorrect syntax near WHEN"
then
if @PrevailingWage is NOT null or @PrevailingWage > 0
begin
set @Message = 'Cannot Use Prevailing Wage With This Step Code'
set @Continue = 0
end
if @Standard is NOT null or @Standard <> 0
begin
set @Message = 'Cannot Use Standard With This Step Code'
set @Continue = 0
end
--Can Not Use Guaranteed Step Wage With This Step Code
if @GuaranteedStepWage is NOT null or @GuaranteedStepWage <> 0
begin
set @Message = 'Can Not Use Guaranteed Step Wage With This Step Code'
set @Continue = 0
end
else
begin
set @Message = 'You did not enter a proper step code.'
end
end
Thanks,
Bill