Help! with ESQL cursors
Posted in 1993
I have having less than an easy time working through the ESQL informix manual. Maybe someone here can give me a hand. I am writing a database server based on informix SE. I get handed a list of field names, and an SQL selection (=WHERE) criteria. Then my caller want to fetch records, generally a few at a time, and see the fields he requested for each. Not terribly complicated. He also wants to know the total number of records his WHERE clause netted. I may well be being dense, but it *looks* as if the only way to do this is to open two cursors, based on the WHERE string I get passed - one cursor to run through, doing FETCHes and counting records so I can get a count; another to do FETCHes as the user calls for them so I can actually return the data. This seems inefficient. Given an existing cursor, is there some way to get another cursor, a duplicate of the existing one? Or do I really have to build 2 cursors from scratch? The problem is made trivially more complicated by the fact that, having generated a cursor, and maybe fetched a few records through it, my caller would really like to know how many records there are *left* to read. Clearly I can count them all up front, and count of records as I read them, and subtract, but that is ugly - and a tad error prone, since it won't account for newly added records. Has anyone faced and solved this one? Mail to me (smayo@world.std.com) would be ideal, but postings are fine too of course. Thanks.