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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: QUESTION
Date: Sep 3 1999 6:05PM

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

In this case it's not needed at all.

I use it (with a redo SWITCH_STATE) when doing error handling or other 
stuff that requires the code to jump from one state to the next.

It just went in there automatically :-)

Michael

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