HOW TO: Go to the last record

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

HOW TO: Go to the last record

Postby Jan Aleman » Mon Dec 15, 2003 11:13 am

The fastest way to do that is to sort by primary key (or creationdate) descending. Alternatively you can use this method:

while(controller.recordIndex < controller.getMaxRecordIndex())
{
controller.recordIndex = controller.getMaxRecordIndex()
}

The latter will be much slower.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby Harry Catharell » Mon Dec 15, 2003 7:32 pm

Hi Jan,

Interesting post !

I assume that you are saying that, in Servoy, sorting is going to be a faster process than a 'while' loop that has to run through all records to give you a result !?

But, why do you need to loop through the records to compare the current record with the maximum ?

I have set up a global method called 'rec_last' as follows :

currentcontroller.recordIndex = currentcontroller.getMaxRecordIndex()
forms.nav.elements.button_first.enabled = true
forms.nav.elements.button_last.enabled = false

Which moves me to the last record in the foundset without any comparison needing to be made !

Admittedly, I have not used this in any table where there are high volume records, but it seems pretty responsive and it works !

I also have a method : 'rec_first' as follows :

currentcontroller.recordIndex = 1
forms.nav.elements.button_first.enabled = false
forms.nav.elements.button_last.enabled = true

Which moves me to the first record in the foundset......

Am I doing something fundamentally wrong here and I just have not had the solution reach a point where it will not perform correctly !??

I am certainly interested in your take on this.

Regards
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby IT2Be » Mon Dec 15, 2003 7:59 pm

Hai Harry,

Your suggestion

currentcontroller.getMaxRecordIndex()


Gives you the last record of, indeed, the current controller.

The current controller however is limited to a max number of records of 200.

So, if you have something like 1000 records your last record would be number 200 and not number 1000.

That's the reason behind the tip. The reason for the limitation is speeeeeeeeeeed (at least that's what I have been told).
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Harry Catharell » Mon Dec 15, 2003 8:45 pm

Hi Marcel,

Thankyou for the explanation.

Because of small volume record numbers that I have been experimenting with, I had no idea that there was a limitation in the record indexing function !

To all : Is there a list of this and any other limitations anywhere in the documentation so that I can familiarise myself with them ?

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby IT2Be » Mon Dec 15, 2003 11:00 pm

Yep, Just play with it and download/read the manuals. On top of that.... Use this forum!

Enjoy, you will love most of Servoy. What you don't love just shout it out.

The guys from Servoy will help you...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Aleman » Tue Dec 16, 2003 12:00 pm

Harry Catharell wrote:
To all : Is there a list of this and any other limitations anywhere in the documentation so that I can familiarise myself with them ?


That depends on your definition of limitation. In my opinion it's not a limitation but a feature. It just works differently than for example desktopdatabases and although Servoy has the ease of use of a desktop database it is a front-end to SQL systems where having a total record count at all times is not feasible.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby chris » Sun Jan 18, 2004 2:36 am

I can't make this work. Here's the situation:

User performs a query of people and the found set contains 750 records. User sorts alphabetically by lastname. Then wants to start at everyone with lastname starting with "Z." In FM, user would just click "go to last record." How would this be accomplished in Servoy? (Obviously user could sort in descending order, but this isn't preferred so let's take it off the table)

I appreciate the superior caching abilities of Servoy, but we've got to find a way around this I think.

Thanks.
chris
 
Posts: 82
Joined: Wed Dec 31, 2003 8:24 pm

Postby jcompagner » Sun Jan 18, 2004 2:12 pm

this i personally really don't get this..
If you want to start wit Z, order then descending!!
That is just the way you should do it..

of course you can with 750 record jump fast to that last record with the code the code also listed above.


Code: Select all
while(controller.recordIndex < controller.getMaxRecordIndex())
{
controller.recordIndex = controller.getMaxRecordIndex()
}
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby chris » Sun Jan 18, 2004 10:00 pm

Thanks Johan. I still think the 200 record caching is great, but I wonder if there could be a feature that allows us to request that Servoy caches all records, or to set manually the number of recs returned at a time.

If not, this is a lower priority at leas tfor me than other things. Thanks again.
chris
 
Posts: 82
Joined: Wed Dec 31, 2003 8:24 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 6 guests