In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (R. Joseph Newton) writes:
>Jeff 'japhy' Pinyan wrote:
>
>>
>> The way I've done this is:
>>
>>   use DBI;
>>   use CGI 'param';
>>
>>   my $dbh = DBI->connect($dsn, $username, $password, { RaiseError => 1 });
>>   my $offset = param('offset') || 0;
>>   my $limit = 10;
>>   my ($prev, $next) = ($offset - $limit, $offset + $limit);
>>   $prev = 0 if $prev < 0;
>>
>>   my $query = qq{ SELECT * FROM table WHERE f=? LIMIT $offset, $limit };
>>   my $n_query = qq{ SELECT * FROM table WHERE f=? LIMIT $next, 1 };
>>   my $arg = param('arg');
>
>Cool.  Definitely a neater solution than the one I proposed, as long as the DB
>supports cursors.  I'm not sure,
>how generally are they supported?  It seems like the result set would have to
>be stored somewhere between
>calls, too, in such a scenario.

Not strictly necessary, but desirable for performance.

Oracle has a different syntax: ...WHERE ROWNUM BETWEEN $offset AND $next

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to