Re: ESQL C and sqlerrd[2]
Posted in 1992
Kristen Altman writes: >I am receiving replies to my original message about fetch >returning 0 in sqlerrd[2] while sqlcode = 0. The messages >all say that sqlerrd[2] does not return the number of rows. > >I am using ESQL/C version 4.1 and sqlerrd[2] DOES return the >number of rows in the active set. This application I have >written works 99% of the time with sqlerrd[2] returning the >number of rows. In fact, I got the idea to look at that >variable for the number of rows from Dave Snyder (and I believe >he knows what he is talking about). > >In the ESQL/C manual it saya: > ... > sqlerrd[2] is the number of rows processed. > ... > >Therefore, does anyone have any idea what's going on with >this?? I thought we had covered this, but I guess not. It does indeed contain the number of rows processed. The question is, when does it get filled in? When you use a cursor, a bufferfull of rows are gathered by your server, and sent to the client when requested by a fetch. If all the rows in your set will fit in the buffer, then the entire number of rows returned is known, and sqlerrd[2] is filled in. If the buffer will NOT hold the entire set, then only a bufferfull is retrieved, and the total number of rows in the set is not known. When the last bufferfull is retrieved from the db, the number will be known and sqlerrd[2] will be filled in. SO 99% of the time, you are getting all your rows in the first bufferfull. The remaining 1% of the time require more than a single buffers worth. In those cases sqlerrd[2] will be filled in after the fetch that causes the last bufferfull to be retrieved. Dave -- Disclaimer: These opinions are not those of Informix Software, Inc. ************************************************************************** "I look back with some satisfaction on what an idiot I was when I was 25, but when I do that, I'm assuming I'm no longer an idiot." - Andy Rooney