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: "Athey, Keith" <Keith dot Athey at TWC dot STATE dot TX dot US>
Subject: RE: sybperl sql batch
Date: May 5 1998 2:34PM

For his next trick, Michael Peppler will institute a script for world
peace.

> -----Original Message-----
> From:	Michael Peppler [SMTP:mpeppler@MBAY.NET]
> Sent:	Tuesday, May 05, 1998 9:03 AM
> To:	SybPerl Discussion List
> Subject:	Re: sybperl sql batch
> 
> John Dubchak writes:
>  > > open(BATCH, $file);
>  > > while() {
>  > > 	if(/^go/) {
>  > > 		$dbh->dbsqlexec;
>  > > 		while($dbh->dbresults != NO_MORE_RESULTS) {
>  > > 			while(@d = $dbh->dbnextrow) {
>  > > 				print "@d\n";
>  > > 			}
>  > > 			if(@d = $dbh->dbretdata) {
>  > > 				print "@d\n";
>  > > 			}
>  > > 			if($dbh->dbhasretstat) {
>  > > 				print "Return status: $dbh->dbretstatus,
> "\n";
>  > > 			}
>  > > 		}
>  > > 	} else {
>  > > 		$dbh->dbcmd($_);
>  > > 	}
>  > > }
>  > 
>  > Ok, now do that with the CT-Lib extensions...
>  > 
>  > :-)
> 
> As they say in French - chiche!
> 
> [ WARNING - typed directly into the mail client - not tested! ]
> 
> open(BATCH, $file);
> $buf = '';
> while() {
> 	if(/^go/) {
> 		$dbh->ct_execute($buf);
> 		while($dbh->ct_results($restype) == CS_SUCCEED) {
> 			if($dbh->ct_fetchable($restype)) {
> 				if($restype == CS_STATUS_RESULT) {
> 					@d = $dbh->ct_fetch;
> 					print "Return status: $d[0]\n";
> 					while(@d = $dbh->ct_fetch) {
> 						;
> 					}
> 				} else {
> 					while(@d = $dbh->ct_fetch) {
> 						print "@d\n";
> 					}
> 				}
> 			}
> 		}
> 		$buf = '';
> 	} else {
> 		$buf .= $_;
> 	}
> }
> 
> 
> Michael
> -- 
> Michael Peppler         -||-  Data Migrations Inc.
> mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
> Int. Sybase User Group  -||-  http://www.isug.com