Hi,
I have a stored procedure with a flag param.. let's call it 'iscurrent'. Based on the value of iscurrent, which block of code would you use in your stored procedure?.. basically, I'm wondering if it makes sense to have a check of iscurrent at every iteration in the WHILE loop or execute a separate block completely when iscurrent = 1 ( it just makes the procedure longer and there is repeating of certain statements that are common to both cases, that is when iscurrent = 0 or 1) .. thanks!
Sorry about the lack of indentation -- it's doesn't seem to work!
SOLUTION 1 --
IF iscurrent = 1 THEN
WHILE (endInterval <= endTime) DO
-- statement 1
-- statement 2
--- extra statements that need to be executed when iscurrent = 1
END WHILE;
ELSE
WHILE (startTime <= endTime) DO
-- statement 1
-- statement 2
END WHILE;
END IF;
OR
SOLUTION 2 --
WHILE (startTime <= endTime) DO
-- statement 1
-- statement 2
IF iscurrent = 1 THEN
---- statement 3
ELSE
---- statement 4
END IF;
END WHILE;