Re: No. of rows selected
Posted in 1998
Harrison Gold wrote: > > Jacob Salomon wrote: > > > Adam Sorati wrote: > > > > > > Informix On-line 5.x > > > ISQL 4.x > > > > > > Hello, > > > > > > I have a cursor in which I create from a query by example, I then use > > > a foreach statement to display each row. Is there anyway of displaying > > > the total number of records selected to the user. I looked at the > > > value of SQLCA.SQLERRD[3] directly after the foreach statement but it > > > always has a value of zero. > > > > > > I am currently using a second cursor to select the count(*) which is > > > making the selection very slow because I'm doing 2 selection. > > Why don't you use a single Integer or Smallint variable as a counter? If > you are using a foreach loop (as opposed to fetching each row), the computer > fetches all the rows of your cursor within your foreach loop. Just set the > counter variable to zero before the foreach statement, then within the > foreach loop, increment it by one. > > Hope this helps. > > Harris > harris@traderpub.com The problem is that FOREACH does a CLOSE at the end. The value you are reading is from the CLOSE statement, which knows nothing about selected rows. You do need a counter. -- Peter Lancashire Information Systems Specialist, Bayer plc Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK Tel: +44-1635-562258, Fax: +44-1635-562281 Mail: Peter.Lancashire.PL1@bayer.co.uk --- My Internet plumbing does not allow me to mail and post news together. Sorry. All opinions are my own and not those of Bayer plc. --- Join Infuse, the UK Informix User Group at http://www.infuse.co.uk/