brgdotnet
asked on
How to execute code based upon the result of a select statement
How do I execute a block of code, if the result of my select statement is true or false? See lines 6 through 13 below, where I have pseudo coded it.
-- I have a table named zoop with a column named Code
1 SET @CODE = RandomCode()
2 SET @COunter = 0
3 SET @ItemFound = 0
4 WHILE @Counter < 1000
5 BEGIN
6 SELECT IF zoop.Code = @CODE THEN
7 -- Perform SQL
8 -- Perform SQL
10 ELSE
11 -- Perform SQL
12 -- Perform SQL
13 SET @CODE = RandomCode() -- Part of ELSE code bloc
14 SET @Counter = @Counter + 1 -- Always do this as the last line in the loop
15 END
-- I have a table named zoop with a column named Code
1 SET @CODE = RandomCode()
2 SET @COunter = 0
3 SET @ItemFound = 0
4 WHILE @Counter < 1000
5 BEGIN
6 SELECT IF zoop.Code = @CODE THEN
7 -- Perform SQL
8 -- Perform SQL
10 ELSE
11 -- Perform SQL
12 -- Perform SQL
13 SET @CODE = RandomCode() -- Part of ELSE code bloc
14 SET @Counter = @Counter + 1 -- Always do this as the last line in the loop
15 END
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER