Re: Help! with ESQL cursors
Posted in 1993
Quoting Bill Foote... } } In article <1nh2s6INN4e0@emory.mathcs.emory.edu> dave.snyder@snide.com (Dave Snyder) writes: } >The way I've handled this is as follows: } > } > 1) Declare a cursor that selects just the rowid(s) based on the user's WHERE } > clause. } > 2) Declare another cursor that selects everything based on a rowid. } > 3) Open the first cursor and fetch all the rowid(s) into a malloc'ed array of } > integers and free that 1st cursor. } > 4) Use whatever logic you want to move back and forth through the array of } > rowid(s). } > 5) Open the second cursor with the current array element's stored rowid, fetch } > the data into local variables, and close the second cursor. } } and hope that the record hasn't been deleted. } Why? What I didn't mention, but a good programmer always does, is check the value of sqlca.sqlcode. If the row is gone for whatever reason, you print a message to that effect. } Out of curiosity... Does db4glgen increase array size linearly or } geometrically? } Memory is realloc'd on an as-needed basis (linearly). DAS -- David Snyder @ Snide Computer Services - Folcroft, PA Current Release is db4glgen-3.9 UUCP: ..!uunet!das13!dave INTERNET: dave.snyder@snide.com