PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: phil_groce at cmcsmart dot com (Phil Groce)
Subject: RE: return only a subset of a result
Date: May 22 1998 12:38AM

At 04:21 PM 5/21/98 -0700, Tim Holt wrote:
>But what if you were trying to do a search that showed "results n to
>n+10 of x"? It's not a matter of reducing to a smaller subset for the
>point of data, but rather for the point of a user?

I haven't tested this, but it seems like you should be able to send "set
rowcount x" to the connection prior to the select.  Use "set rowcount 0" on
the handle to reset it.  Off the top of my head...

use Sybase::CTLib;
$dbh = new Sybase::CTLib 'user', 'pass', 'server';
$dbh->ct_sql('set rowcount 10');
$dbh->ct_execute('your query here');

# handle results, etc....should only get 10 rows

$dbh->ct_sql('set rowcount 0');  # Now it will return full result sets

Well, that's the principle;  I've probably screwed up the details.  I've
never had to do this in Sybperl, but we use web.SQL a lot here, which is an
almost identical animal (I understand the two ct_lib's share a common
codebase), and I've used something like that quite a few times there,
mostly to get the x most recent records by timestamp.  (AFAIK, "set
rowcount" used with the ORDER BY clause is the most efficient way to
determing the "x most recent records" or "top x records".)

What's really fun is playing with 'set showplan on' and other diagnostics.
Has anyone experimented with DBCC's thru Sybperl? (Not something I'd
personally try except on a test box, incidentally....)

>-------------
>Tim Holt, Webmaster
>Rogue Wave Software
>http://www.roguewave.com

phil groce
CMC, Inc