Subject Re: [ib-support] Data paging question
Author Frank Ingermann
Hi,

pablosanchezuy wrote:
> Hello, i´m a Clarion developer using Firebrid through odbc access,
> (easysoft). We have a question i have no elements to answer and would
> like to know.
> When a query is sent to the server, it receives it, and if applicable,
> dispatches it.
> What happens with the number of records sent to the client ?
> Eg: Select bla bla from mytable where condition_met , retrieves
> let´s say 150 records.
> In this case i want to "page" in 25 record pages.
> Does the server sends all of such records or do i have to specify with
> a "limit" clause the number of records i need at a time ?
> Eg: Select bla bla from mytable where condition_met "limiting to 25"
> Maybe there is a server setting to set to send "n" records at a time ?
> Where can i find docs about such features ?
> Thanks in advance.

How many records the server returns depends on the access method: BDE always
returns the entire result set, with e.g. IBObjects you have more control through
the MaxRows property - but you can only limit the count of records from the
start, not from somewhere in the "middle". (Technically the server returns one
row for each FETCH command sent by the client, but it depends how and when your
access components issue those FETCHes)

for the "paging" function: With Firebird you can use the FIRST and SKIP clauses
in Select statements to do that. Excerpt from the FirebirdRefGuide.pdf: Syntax
for SELECT

<quote>
SELECT [TRANSACTION transaction]
[ {[FIRST int] [SKIP int]} ] <-------!
[DISTINCT | ALL]
{* | <val> [, <val> ...]}
[INTO :var [, :var ...]]
FROM <tableref> [, <tableref> ...]

(...)

FIRST m returns an output set consisting of m rows, optionally
SKIPping n rows and returning a set beginning (n+1) rows from the
?top? of the set specified by the rest of the SELECT specification. If
SKIP n is used and the [FIRST m] parameter is omitted, the output set
returns all rows in the SELECT specification except the ?top? n rows.
These parameters generally make sense only if applied to a sorted set.
</quote>

so you could SELECT FIRST 25 SKIP 0... for the first page and
SELECT FIRST 25 SKIP 25... for the second etc.

IB6.5 has something like this, too - but iirc Borland uses TOP and LIMIT
keywords for the same purpose and the syntax is somewhat different...

hth,
fingerman
--

-------------------------------------------------------------------------
when parsers parse, and compilers compile, then why don't objects object?

fingerbirdy - fingerman's door to Firebird
http://www.fingerbird.de