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: Adam Witney <witneya at nmripo dot nmri dot nnmc dot navy dot mil>
Subject: Re: QUESTION
Date: Sep 3 1999 6:00PM

probably just a perl question rather than Sybperl, i was just wondering
what the SWITCH_STATE does and why you need it?



>#!/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; >