Re: Foreach statement
Posted in 1997
Jake, Damn, I didn't know that was a bug - I thought it was an undocumented feature! You are right, of course - this is a bad practice. I'd change all my apps that do this, but I've got so many "go to's" in the code that I can't make changes easily (ha ha ha). All seriousness aside, I suspect we'll all be 6 feet under before Informix gets around to fixing this. Nonetheless, I shall instruct my staff (and myself) that abusing the foreach statement is no longer part of our coding standard. Thanks for pointing this out. Jim Jacob Salomon wrote: > Jim, > > since the FOREACH is [allegedly] the equivalant of an OPEN, the > FOREACH > should be close the cursor and reopen it, just as an explicit OPEN > would > do. You are correct; the FOREACH has been behaving this way. > However, > this is incorrect behavior for the FOREACH. > > I found this code all over the place at my place and was quite annoyed > > at this abuse of what is really a bug (IMO). I reported it to > Informix > as such. One of these days, some well-meaning purist will fix this > bug > (I wonder if this works in ESQL also) and break an awful lotta code > out > there. Then I'll be gloating: "See? I told you so!" ;-) > > Jim Young wrote: > > > > Undocumented feature: > > > > For the older versions, you can do an open using statement, then do > > your foreach statement without a using clause - it works just like > > you had a using clause on the foreach. > > > > Denis Cloutier wrote: > > > > > Hello, > > > I was at the Informix > > > conference a couple of weeks ago > > > and went to the 4gl-Tips and > > > Tricks track. At that seminar, I > > > could swear I heard someone > > > mention that a "using" clause > > > could be used with a foreach > > > statement now. Is this true? > > > > > > Thanks in advance, > > > Denis J. Cloutier > > > Systems Analyst/Programmer > > > Yankee Candle Company > > -- > -- Jake (In pursuit of undomesticated aquatic avians) > > +----------------------------------------------------------+ > | Inscription on the headstone of a hypocondriac: SEE? | > +----------------------------------------------------------+