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: "ye, wei" <yw at alabanza dot net>
Subject: Re: Moving to a specific row
Date: Aug 31 2000 6:25PM

Michael Peppler wrote:

> Andrew Armstrong writes:
>  > I routinely have to report large numbers of database table rows to a web page
>  > and was having a problem limiting the number of rows I display using the
>  > standard CTlib methods. I can use set rowcount xxxx but this only limits the
>  > resultset to the first xxxx rows. I want to be able to move the resultset to a
>  > row that I choose. I can do this in PHP and was wondering how the best way to do
>  > this in Perl would be.
>  >
>  > The only solution that i have found is to call ct_fetch() xxxx times and ignore
>  > the results or to use ct_sql to move the results into an array and start at the
>  > xxxx element. Neither of these seem very good for system performace.
>  >
>
> I don't see how PHP could do this any better than perl. It is limited
> by what Sybase understands, and in this particular case it is limited
> by the way SQL works.

Just read PHP Sybase module, it seems that in sybase_query(), it reads
*ALL* results into memory, then it can use sybase_data_seek() to locate record
position later.

PHP_FUNCTION(sybase_query)
       ...
       ...
        while (retvalue!=FAIL && retvalue!=NO_MORE_ROWS) {
                result->num_rows++;
                if (result->num_rows > blocks_initialized*SYBASE_ROWS_BLOCK) {
                        result->data = (pval **) erealloc(result->data,sizeof(pval
*)*SYBASE_ROWS_BLOCK*(++blocks_initialized));
                }
                result->data[i] = (pval *) emalloc(sizeof(pval)*num_fields);
                for (j=1; j<=num_fields; j++) {
                        php_sybase_get_column_content(sybase_ptr, j,
&result->data[i][j-1], column_types[j-1]);
                        if (!php_sybase_module.compatability_mode) {
                                convert_to_string(&result->data[i][j-1]);
                        }
                }
                retvalue=dbnextrow(sybase_ptr->link);
                dbclrbuf(sybase_ptr->link,DBLASTROW(sybase_ptr->link)-1);
                i++;
        }
}


>
>
> As SQL is set-based you can't say "get me rows x through y". Instead
> you have to use an appropriately constructed where clause that will
> give you the next x rows.
>
> Michael
> --
> Michael Peppler         -||-  Data Migrations Inc.
> mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
> Int. Sybase User Group  -||-  http://www.isug.com
> Sybase on Linux mailing list: ase-linux-list@isug.com

--

Sincerely,

Wei Ye