BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get next/prior

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Lasse
Guest





PostPosted: Mon Dec 13, 2004 11:29 pm    Post subject: How to get next/prior Reply with quote



Hi, I want to retrieve one record at the time from a large table with prior
and next. I get the first record easily by using a parameterized TSQLQuery,
but how do I do to get the next/prior record now?. If I retrieve all records
I can use findkey and prior and next on the ClientDataset, but retrieving
all records is not efficient. Does anyone have some tips on how to do this?
Thanks, Lasse


Back to top
Bill Todd
Guest





PostPosted: Tue Dec 14, 2004 1:07 am    Post subject: Re: How to get next/prior Reply with quote



What database are you using?

Since relational databases have no concept of ordinality the only way
to get rows in a particular order is by using an ORDER BY clause. Since
dbExpress dataset components provide a read only forward only cursor
the only way to provide bidirectional scrolling is to load the data
into a ClientDataSet.

How many rows do you need to scroll through?

It might help to know what you are trying to accomplish.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
Back to top
Lasse
Guest





PostPosted: Tue Dec 14, 2004 5:05 am    Post subject: Re: How to get next/prior Reply with quote



I am using ms sql 2000, Delphi7.
It is a form where the user can retrieve a record by searching and then use
the next or prior to step.
At the moment I am loading all records into the clientdataset and using
findkey, prior, next. Its fast to step back and forward but it starts to
take time to load as the number of records is growing and I really only need
one record in memory at the time. The number of records I need to scroll
through is not so many, the number of records I load to the clientdataset is
probably a couple of thousands.
Lasse

"Bill Todd" <no (AT) no (DOT) com> skrev i meddelandet
news:41be3cc0$1 (AT) newsgroups (DOT) borland.com...
Quote:
What database are you using?

Since relational databases have no concept of ordinality the only way
to get rows in a particular order is by using an ORDER BY clause. Since
dbExpress dataset components provide a read only forward only cursor
the only way to provide bidirectional scrolling is to load the data
into a ClientDataSet.

How many rows do you need to scroll through?

It might help to know what you are trying to accomplish.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email



Back to top
Bill Todd
Guest





PostPosted: Tue Dec 14, 2004 1:57 pm    Post subject: Re: How to get next/prior Reply with quote

You are trying to do something that TClientDataSet and SQL database
servers in general where not designed to do well and that is to scroll
through a large number of row. Personally, I have never seen a user
that wants to look for a record manually by scrolling through more than
100 rows at the most.

If the user needs to see the rows that are close to the row he/she is
searching for then use a SELECT with a reasonable range in the WHERE
clause. For example, if the user searches for a row with a value of 5130
use WHERE AFIELD > 5120 AND AFIELD < 5140. The idea is to fetch a small
number of rows with each SELECT and run another SELECT when you need
more rows. This is the architecture that SQL database servers were
designed to support well.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
Back to top
Lasse
Guest





PostPosted: Tue Dec 14, 2004 10:26 pm    Post subject: Re: How to get next/prior Reply with quote

Thank you for the advise!

"Bill Todd" <no (AT) no (DOT) com> skrev i meddelandet
news:41bef130$1 (AT) newsgroups (DOT) borland.com...
Quote:
You are trying to do something that TClientDataSet and SQL database
servers in general where not designed to do well and that is to scroll
through a large number of row. Personally, I have never seen a user
that wants to look for a record manually by scrolling through more than
100 rows at the most.

If the user needs to see the rows that are close to the row he/she is
searching for then use a SELECT with a reasonable range in the WHERE
clause. For example, if the user searches for a row with a value of 5130
use WHERE AFIELD > 5120 AND AFIELD < 5140. The idea is to fetch a small
number of rows with each SELECT and run another SELECT when you need
more rows. This is the architecture that SQL database servers were
designed to support well.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.