Subject | RE: [firebird-support] How do I read a specific range of records from a table in the database |
---|---|
Author | Rudy Popeszku |
Post date | 2013-01-21T21:20:44Z |
Ann,
Thanks,
You are right, I am not sure how it was working but it should have been
"SELECT COUNT(*) FROM SURFACE"
SELECT FIRST n FROM only reads the first "n" records I want to read the last
"n" records to the end of the DB
FYI, I am a newbie to SQL so I don't know the command syntax very well. What
I need is something like SELECT LAST n FROM but when I tried that I get an
error.
Is there something similar?
Can you provide an example on your next reply please?
Rudy
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ann Harrison
Sent: Monday, January 21, 2013 2:46 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How do I read a specific range of records
from a table in the database
On Mon, Jan 21, 2013 at 2:59 PM, HotRodRudy rpopeszku@...
<mailto:rpopeszku%40aps-tech.com> > wrote:
way to say SELECT COUNT(*) FROM SURFACE, but Firebird almost certainly does
the necessary transformation.
10%?) in a table, I guess you could start by reading all of them, dividing
the count by 10 and then reading only that number, but that's a very
inefficient way to handle the problem.
If you know that you want 50 or 100 records, fine, ask for that many, but
ask for them sorted by some field so you have a change of knowing which
records you're getting.
Good luck,
Ann
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Thanks,
You are right, I am not sure how it was working but it should have been
"SELECT COUNT(*) FROM SURFACE"
SELECT FIRST n FROM only reads the first "n" records I want to read the last
"n" records to the end of the DB
FYI, I am a newbie to SQL so I don't know the command syntax very well. What
I need is something like SELECT LAST n FROM but when I tried that I get an
error.
Is there something similar?
Can you provide an example on your next reply please?
Rudy
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ann Harrison
Sent: Monday, January 21, 2013 2:46 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How do I read a specific range of records
from a table in the database
On Mon, Jan 21, 2013 at 2:59 PM, HotRodRudy rpopeszku@...
<mailto:rpopeszku%40aps-tech.com> > wrote:
> Support,You can using something like SELECT FIRST FROM
>
> I am using Firebird server 2.5.2, Windows 7, and Visual Basic 2010.
>
> I would like to read a certain # of records from a table in the database
> using a start / stop record range. I am trying to re-write an application
> written by someone else which reads the entire database from beginning to
> end which takes a long time and I may only need the last 1000 records of a
> database that can have over 100,000.
>
>That's going to read every record in the database. It's also a very odd
> I have been using the following to determine the total number of records
> in the database so I should be able to use it to establish a range.
>
> 'Find the total number of records in the SURFACE table
> Dim count As FbCommand = New FbCommand("SELECT COUNT(*) FROM ( select *
> from SURFACE )", fbc)
>
way to say SELECT COUNT(*) FROM SURFACE, but Firebird almost certainly does
the necessary transformation.
> Dim readCount As FbDataReader = count.ExecuteReaderIf you're trying to do something like reading 10% of the records (which
> readCount.Read()
> lastDbRecord = readCount.GetValue(0) ' Get the total number of records in
> this database
>
>
10%?) in a table, I guess you could start by reading all of them, dividing
the count by 10 and then reading only that number, but that's a very
inefficient way to handle the problem.
If you know that you want 50 or 100 records, fine, ask for that many, but
ask for them sorted by some field so you have a change of knowing which
records you're getting.
Good luck,
Ann
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]