My gripe today
I have been asked to look into why a stored procedure is failing. The problem is that the application gets an error that a temp table doesn't exist. Here is the code with the problem (my comments in blue, contents were changed to protect company information):
FETCH NEXT FROM @cursor
The WHILE statements should be reversed. The first one should be WHILE @@FETCH_STATUS = 0, and the second one should be WHILE @@FETCH_STATUS <> 0. If there was ever a time where the temp table didn't have any records, the stored procedure would go into an infinite loop. Also, the other records in the temp table never get processed since it drops the temp table before doing anything with them.
Now I didn't write the stored procedure but need to fix it. Just complaining...
Legacy Comments
jw
2005-09-12 |
re: My gripe today .....and 2 years years, (nearly to the day), i stumble across your meassage.... No answer though, sorry. Just thought I'd say I agree with you. I was looking at exactly the same example a few weeks ago and thought exactly the same thing. Ho hum. |