Re: 4GL Programming tidbit
Posted in 1997
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
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?