more useful options | |
PerlMonks |
Re: Perl DBI MS SQL Questionby sedhed (Scribe) |
on Jul 12, 2002 at 22:33 UTC ( [id://181413]=note: print w/replies, xml ) | Need Help?? |
Regarding the first problem (limiting results to page-size subsets with MS SQL), I use a nested select that I picked up from a DBA much craftier than myself, and I use it in code like the following (using an arbitrary 'parts' table with fields 'partno' and 'custno'):
The main select gets everything past the $offset, it's then wrapped in a select that flips the order and gets just the TOP $reccount of the first set, in turn that's wrapped in a last outer select which just flips the order back right-side-up. Anyone else use something like this? I know I'm wasting a few cycles doing the $totalcount lookup, but I also use that number to generate the page navigation links. In fact, I might ask for critique of my navLinks() sub here at some point, I think it's kinda nifty.
In Section
Seekers of Perl Wisdom
|
|