|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: sybperl sql batch
Date: May 4 1998 8:12PM
Simon Yaminian writes:
> hello,
>
> My name is Simon Yaminian and I would like to know if Sybperl has the
> capacity to run batches of sql commands stored in a file. The batch file
> can contain flow control logic statements like if, goto, etc.
>
> I appreciate your prompt reply in advance.
Sybperl can run anything that isql can, but it does not understand the
'go' command separator.
The following code fragment would basically execute a sql batch the
same way as isql:
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($_);
}
}
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
|