"Amit Saxena" schreef:
> Dr.Ruud:
>> jm:

>>> there is a LIMIT option for the SELECT statement that will return
>>> the number of records you desire.
>>>
>>> $sth = $dbh->prepare("select <whatever> from <table> <optional WHERE
>>> arguments> LIMIT <desired number of records>");
>>> $sth->execute();
>>>
>>> while ($vars ...) = $sth->fetchrow_array())
>>> {
>>> }
>>> # or whatever syntax best suits your preferences
>>
>> That won't always work as you expect it. You need to give values for
>> the ORDER BY and OFFSET and LIMIT, but between queries there can be
>> new rows inserted or deleted, so you might get the same row again,
>> or miss new ones.
>> [snipped signature, one should never quote signatures]
>
> What about the scenario when the table is accessed in a read-only
> mode ?


Things get mixed up now. One technique is the one documented in the DBI
documentation (as I quoted), the other technique is doing repeated
queries with changing offset. Both have their uses.

> Also I want to know whether the subsequent calls to fetchrow_array
> will actually fetch the next LIMIT records or the current LIMIT one.

The query that you prepared for a "fetchrow_arrayref() with a
$max_records parameter" can have a SQL-LIMIT value, but that value is of
course normally greater than the $max_records value.
The $max_records value is the number of rows (or chunk size) that you
want to work on at the same time.
The SQL-LIMIT value is the maximum number of rows that the query returns
(in total).

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to