>Part of the fun of this one is that it is not duplicatable -- that is, the code my run for months (a dozen times a day for the main loop, these lines of code a few thousand times within that loop) with no errors, and then it may start failing. When it does fail, running it again on the same data may not fail at all, or may fail on different data.
In very general terms, the fact that some program error happens sometimes, and sometimes not, MAY indicate a difference in the underlying data. However, I don't see how that can make a difference here. For instance, I thought wrongly that if zero records fulfilled a condition, the cursor would not be created, but already discarded that possibility.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)