writing WHILE loop with 2 conditions

October 23rd, 2008 by Mr.M | 1 Comment »

Thru out the day, I was just hammering out WHILE loops left and right. Everything was going smoothly when looping thru using 1 condition. Cake walk. Then later in the day, I tried to throw in 2 conditions and disaster struck. The damn script never made it into the WHILE loop. It took me about 30 minutes, plus another 10 minutes discussing WHILE loop w/ a C# dev, and another 30 hammering away with my lead. We couldn’t figure it out. The syntax look like this:

Finally, after all that time, I spoke to another C# dev, who was a bit more interested in trying to help me out. I was told that the WHILE loop conditions has to be both TRUE or both FALSE! My WHILE loop will always have 1 condition equal to TRUE (except for once a day) while the other is equal to FALSE. True enough, when both conditions are either TRUE or FALSE, the WHILE loop work flawlessly.

I wonder if this is different in C/C++/C#. I’ll have to find out.

So, I went to back to the drawing board and came up with the following alternative:

One Response to “writing WHILE loop with 2 conditions”

  1. Obe says:

    WHILE loop in SQL and C# function exactly the same.

Leave a Reply

You must be logged in to post a comment.