Re: I4gl query
Posted in 1998
On Tue, 15 Dec 1998, Tony Flaherty wrote: > Jonathan Leffler wrote in message <74mk03$poq$1@news.xmission.com>... > >This works, but if you're going to do it often, you'd be better off doing: > > > > DEFINE l_tt_accno integer > > LET sel_stmt = "SELECT COUNT(*) FROM tt_extract WHERE tt_accno = ?" > > PREPARE count_rec FROM sel_stmt > > DECLARE cursor_count CURSOR FOR count_rec > > FOREACH cursor_count USING l_tt_accno INTO no_of_rec > > EXIT FOREACH > > END FOREACH > > I don't think you can use FOREACH with a prepared statement using > place holders! You have to open and fetch the cursor manually. > This may well be a version dependant limitation. I think you can. In fact, I know you can. It was one of the changes put into I4GL while I was leading the team that maintained I4GL. But you're right -- it is version specific. I think that change arrived with 4.14/6.02 I4GL, though it might have been 4.13/6.01. Either way, if it isn't available to you, it is high time you upgraded to a DBCENTURY-aware version of I4GL -- 380 days or so left! Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn PS: Try it! eg: fglpc foreach.4gl && fglgo foreach.4gl 100 110 120 # I4GL-RDS or: c4gl -o foreach foreach.4gl && ./foreach 100 110 120 # I4GL or: fgl2p foreach.4gl && fglrun foreach.4gl 100 110 120 # D4GL DATABASE stores7 MAIN DEFINE i INTEGER DEFINE n INTEGER DEFINE b INTEGER PREPARE s FROM "select count(*) from customer where customer_num > ?" DECLARE c CURSOR FOR s FOR i = 1 TO NUM_ARGS() LET b = ARG_VAL(i) FOREACH c USING b INTO n EXIT FOREACH END FOREACH DISPLAY n USING "##&", " customers with number greater than ", b USING "<<<" END FOR END MAIN