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: "BAHRI, SOFIENNE" <sofienne dot bahri at bell dot ca>
Subject: Re: QUESTION
Date: Sep 3 1999 5:40PM

Tkanks for the Answewr

Michael Peppler wrote:
> 
> BAHRI, SOFIENNE writes:
>  > hi,
>  >
>  > I use a cursor because i want to minimize the overhead(ithink). Because
>  > the user normally can get about 1200 records. with he the cursor i can
>  > cash the records and minimize the time to wain for the browser to
>  > display the records.
>  > for the Next Buttom(java) to get the next pages i don't know  another
>  > solution to handle this.
> 
> This is really a CGI problem, rather than a Sybperl problem. However:
> 
> Let's assume that we are retrieving rows from an account table:
>         account(account_no, name, last_change, balance)
> and you want your CGI to be able to page through the account, 10 rows
> at a time.
> 
> You could write your CGI like this (coded right into the mail message
> - so there may be syntax errors!):
> 
> #!/usr/local/bin/perl -w
> 
> use strict;
> use CGI;
> 
> use Sybase::CTlib;
> 
> my $q = new CGI;
> my $dbh = new Sybase::CTlib 'webuser', 'webuser', 'server';
> 
> print $q->header;
> print $q->start_html;
> print $q->start_form;
> 
> my $state = $q->param('__state') || 0;
> 
> SWITCH_STATE: {
>     if($state == 0) {
>         $dbh->{MaxRows} = 10;
>         my $rows = $dbh->ct_sql("select account_no, name, last_change,
> balance from account order by account_no", undef, 1);
>         print "\n";
>         my $last;
>         foreach my $row (@$rows) {
>             print "\n";
>             foreach my $col (keys(%$row)) {
>                 print "";
>             }
>             $last = $row->{account_no};
>             print "\n";
>         }
>         print "
$row->{$col}
\n"; > $q->param('last_account', $last); > $q->param('__state', 1); > print $q->hidden('__state'); > print $q->hidden('last_account'); > print $q->submit('Next'); > } elsif($state == 1) { > my $last = $q->param('last_account'); > my $rows = $dbh->ct_sql("select account_no, name, last_change, > balance from account where account_no > $last order by account_no", undef, 1); > print "\n"; > my $last; > foreach my $row (@$rows) { > print "\n"; > foreach my $col (keys(%$row)) { > print ""; > } > $last = $row->{account_no}; > print "\n"; > } > print "
$row->{$col}
\n"; > $q->param('last_account', $last); > $q->param('__state', 1); > print $q->hidden('__state'); > print $q->hidden('last_account'); > print $q->submit('Next'); > } > } > > print $q->end_form; > print $q->end_html; > > exit; > > If this doesn't make sense, please read the docs for CGI.pm (perldoc > CGI). > > Michael > > > > > > > Michael Peppler wrote: > > > > > > BAHRI, SOFIENNE writes: > > > > Hi folks, > > > > > > > > my question is when i dispaly a page containing 10 records. I have to > > > > dispaly a Buttom named Next(to dispaly the next 10 records). But the > > > > buttom is in javascript. how i can call again the query from a java > > > > code. > > > > > > > > !A part of my perl scrip > > > > $dbh->ct_cursor(CS_CURSOR_CLOSE, undef, undef, CS_DEALLOC) == CS_SUCCEED > > > > || die; > > > > $dbh->ct_send; > > > > print > > > > $q->button(-name=>'next',-value=>'Suivant',-onClick=>"&Next_page"); > > > > print $q->end_html; > > > > > > > > print "deuxieme set"; > > > > Next_page; > > > > }#Fin while ct_results > > > > > > Why is the button a javascript button? > > > Why do you use client-side cursors? > > > > > > 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 > > > > -- > > ----------------------------------------------------------- > > Sofienne Bahri Bell Canada > > > > Directeur-CSR > > 700,De la Gauchetière O., RC Mezz, Montréal (PQ) H3B-4L1 > > Téléphone :+1 514 391 4114 > > Pagette :+1 514 801 2186 > > Email :sofienne.bahri@ bell.ca > > ----------------------------------------------------------- > > > > -- > 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 -- ----------------------------------------------------------- Sofienne Bahri Bell Canada Directeur-CSR 700,De la Gauchetière O., RC Mezz, Montréal (PQ) H3B-4L1 Téléphone :+1 514 391 4114 Pagette :+1 514 801 2186 Email :sofienne.bahri@ bell.ca -----------------------------------------------------------