Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Selects with Pagination - Internet style - optimised
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00711618
Message ID:
00711638
Views:
8
Hi!

No. You have to query TOP 140, and then skip first 6 pages of records. You can solve this puzzle only *partially* by 2 ways:

1. Define a field with an order number of record. So you will always be able to select records that have order number AFTER 200. Something like SELECT TOP 20 ... WHERE OrderNum >200. "200" is an order number of last record displayed on previous page. Does not need to be sequential. You can use real numbers and fractinal part to do not do re-numbering too often. This approach is cumbersome, because as soon as you change sorting order, you need to re-number records order.

2. Cache results in the memory, then display them from cached cursor just by navigation. More, if it is view or SPT cursor, you can make it with option "Fetch As Needed" and this will not download the entire set when you need just first 20 pages (though it would be very hard to get total number of records - you'll need another query for that).

You can also download all data to client and use Java Script to build pages and display them as user navigates information. Client will have to wait a lot, but then no any requests to serevr at all...

>Internet searches/applications return the TOP 20 or so records matching a search criteria and then allow you to PageDown to select the next 20 ... etc.
>
>The first select is easy as it selects the TOP 20. Subsequent SELECTS as the user Pages Down are more difficult to do quickly without having to do a nested select which will be slow.
>Is there a simple way of doing these selects on SQL Server for a specific WHERE clause?
>For example to SELECT TOP 121 TO 140 records if the user wants to see the 7th Page.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform