Re: Foreach statement
Posted in 1997
>Date: Tue, 05 Aug 1997 11:28:28 -0400 >From: Denis Cloutier <DJC@yankeecandle.com> >Subject: Foreach statement > >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? I believe that either Cathy Kipp or I said that. It depends on your version of I4GL, but the answer is YES! I believe it is in versions from 4.14/6.02 upwards. You can now write: LET str = "SELECT X, Y, Z FROM T WHERE P = ? AND Q < ?" PREPARE p_select FROM str DECLARE c_select CURSOR FOR p_select FOREACH c_select USING val1, val2 INTO l_x, l_y, l_z ... END FOREACH Which is more succinct than having to write the loop out longhand as: OPEN c_select USING val1, val2 WHILE sqlca.sqlcode = 0 FETCH c_select INTO l_x, l_y, l_z IF sqlca.sqlcode = NOTFOUND THEN EXIT WHILE END IF ... END WHILE CLOSE c_select You do read the release notes, don't you? Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: Warning I do not reply to messages with anti-spam in the return path.