Re: How big is my result set?
Posted in 2003
You can do a read ahead in your program, whenever user presses next , that is read not only the next, but next and next. This way you will know when to disable the buttons. For start, it is easy, maintain a count variable starting with zero and if count will become zero when previous is pressed , disable previous button. Just ur program needs to take care of this, this might decrease the performance a bit, but since the cursor is already open, it should be affordable. Also you can make up a bit in subsequent next button presses as then you will already have the requested record in program. Rgds Preetinder Scott Burns wrote: >Hi, > I've a google search showed me this question has been mentioned, but >never seems to be asked or anwered directly: > >I am running SE, and have made a select cursor I traverse using "Next" >and "Prev" buttons in my C application. I want my buttons to becomes >insesnsitive when I hit either the start or the end of the set ( cant go >further, and want the user to know that ). > >I have a function that figures out if I'm at the start or end, even >taking into account any records I've deleted from my set ( but which >still have a blank entry ). My application skips over the blank >entries. Unfortunately, I need to know what the theoretically last >entry in the set is, or, in other words, how big is the set I just selected? > >At the moment I traverse the list just after selection but before >display, counting as I go. For a set of 6500 odd records this takes >well over a minute on my hardware. I could use a count(*) but it would >have to be a seperate call. I'm worried that if an entry is added or >deleted my application may either never think it is at the end, or will >miss a record. Is there a way to embed the count(*) into my select >statement I use for my cursor, returning the total count of all rows on >each row? > >My select statements are always in the form "SELECT <key value> FROM ><table> WHERE ..." with no order by, groups etc. > > > > sending to informix-list