Re: 4GL Programming tidbit
Posted in 1997
In article <5gnhhb$d2k@cssun.mathcs.emory.edu>, Jonathan Leffler
<johnl@informix.com> writes
>Opinion -- you're probably using an older version of I4GL again.
>
>Mild Flames -- you forgot to cite which version of the Informix products
> you are using.
>
>Counter-example:
>
>DATABASE stores -- Fix this to any convenient database
>
>MAIN
>
> DEFINE r RECORD LIKE 'informix'.SysTables.*
>
> DECLARE c SCROLL CURSOR WITH HOLD FOR
> SELECT * FROM 'informix'.SysTables>
> FOREACH c INTO r.*
> DISPLAY r.tabname
> END FOREACH
>
>END MAIN
>
I used / upgraded a cursor management library which handled reopening
cursors after a commit etc. The cursors were scroll cursors with hold
and when you opened a cursor it returned the number of rows in the
cursor :-
Let n_rows = 0
FOREACH QC_cursor1 INTO key1,key2,key3,key4,key5,key6
LET n_rows = n_rows+1
END FOREACH
This worked Ok under 4.1 and 6.00/6.01/6.02
Sounds like a 4GL bug...
>This works OK under p-code or c-code with 6.04.UC1 (against 7.21.UC1
>OnLine) on Solaris.
>
>Yours,
>Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>
>}From: Jacob Salomon <jake@apparel.net>
>}Date: Tue, 18 Mar 1997 17:30:14 GMT
>}X-Informix-List-Id: <news.35491>
>}
>}Hi Family (I think I need to get out more.. ;-)
>}
>}Here is a 4GL problem I ran into and solved. It may prove useful.
>}
>}In a previous version of my application, I specified a scroll cursor
>}with hold. For every time the user pressed a navigation key, I would
>}fetch relative +1 or -1... y'know, the classical stuff. Anyway, I
>}changed my mind about navigating by FETCH and decided to use that same
>}cursor to fill an array of primary-key values using a FOREACH loop.
>}
>}I incurred error -229/-102.
>}-229 Could not open or create a temporary file.
>}-102 ISAM error: illegal argument to ISAM function.
>}
>}Huh?
>}
>}On a guess, I took out the "SCROLL" and "WITH HOLD" clauses. The FOREACH
>}now works.
>}
>}Conclusion: the FOREACH loop internal mechanism does not like working
>}on a scroll cursor. (IMO It's unlikely that it is barfing on the WITH
>}HOLD.) I am not prepared to argue that this a product deficiency; after
>}all, a foreach loop has no need for a scroll cursor. But it might be
>}nice if the reference manual warned me about this. And it might be nice
>}if I had the ability to reuse the scroll cursor in a WHILE loop after
>}using it in the FOREACH loop.
>}
>}Opinions? Mild flames?
--
David Williams