dan schreef:
> Amit Saxena:

>> I am looking for a "fetch" function to fetch "n" number of records
>> at a time in Perl DBI !
>
> I had to do this kind of thing to implement 'record paging' in
> Gtk2::Ex::DBI. The way I did it was in a couple of steps.
>
> 1) Run a query to *only* select primary key(s) from the records
> that you want

A table can only have one primary key, so I assume you are talking about
a query on joined tables there.


> 2) Store these primary keys in an array

Since this plural is unconditional, I assume you meant "primary key
values".


> 3) Assemble a query to select the fields you want, and add your
> primary key(s) to the where clause

I often use such a multi-pass approach as well, but it doesn't always
apply.
For example it depends on the kind of joins in your query.
Another thing is that if the set of tables involved is very volatile,
the data can have changed in between the steps.


> DB servers don't guarantee the order that records are returned in
> unless you explicitly add an 'order by' clause and list all relevant
> columns

You should just always have an ORDER BY clause. It will often be the
"expected order", like the primary key, or the aggregation (GROUP BY)
definition, but still you should always mention an order.

-- 
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