Re: 4gl, cursor and count
Posted in 2000
Frank Fischer <FischerF@lsv-gartenbau.de> wrote: > > i have a cursor and i want to now how many records are inside this. > > I don't now the syntax and I couldn't find something in the handbooks. > > Frank Fischer ROBV wrote: > OK my memory is a bit foggy on this one but once you have opened the cursor > can't you check one of the values of SQLCA record to see how many rows were > selected. > Can someone flesh out my memory???...I'm having sometimers disease... > > OPEN cursor_name > Let l_num_rows = SQLCA. something... > > Obnoxio, Art, Someone??? I guess I qualify as "Someone." :) Actually, the sqlca.sqlerrd[3] value is the number of rows processed for the last SQL statement. It will only show the total number of rows if it was for a DELETE or UPDATE; you'll need to do SELECT COUNT(*) WHERE ... to find the number of rows in a cursor. Obviously this can be very time-consuming for some queries.. Another option is to have your 4gl program scroll throgh the cursor and increment a counter before displaying the first row to a user. Yes, I think that's a good way. To avoid re-opening the cursor, however, would need to make the cursor scrollable and the FETCH FIRST after you get your count. Ron ________________________________________________________________________ Ron Flannery <mailto:rflanner@informixhandbook.com>, 248-887-8470x40 Lead author, Informix Handbook President, One Point Solutions "Your Complete Reference" "Informix & Web/Database solutions" http://www.informixhandbook.com http://www.one-point.com ________________________________________________________________________ > Rob Vorbroker