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: "John Portis" <jportis at fnx dot com>
Subject: Re: Using files to load database objects
Date: Jul 12 1999 10:06PM


Thank you.  How does one emulate the go statement?





Michael Peppler  on 07/12/99 05:56:22 PM

Please respond to SYBPERL-L@listproc.net

To:   SybPerl Discussion List 
cc:    (bcc: John Portis/Wayne/FNX)

Subject:  Re: Using files to load database objects


John Portis writes:
 >
 > I am trying to read a file that already has the sql for loading a
database
 > object (e.g. loads numerous triggers).  I've tried to join the file in a
 > variable and then execute.  I've also tried to keep calling
 > dbh->dbcmd("$_") and at the end of the file call dbh->dbsqlexec. I don't
 > know how to get the whole script into the one dbcmd.

Normally, something like this should work:

while(<>) {
   dbh->dbcmd($_);
}
$dbh->dbsqlexec;
while($dbh->dbresults != NO_MORE_RESULTS) {
    while(@d = $dbh->dbnextrow) {
     print "@d\n";    # just in case...
    }
}

However, if your load script has 'go' statements in it (that would
normally be interpreted by isql) then you'd have to emulate that in
the loop too.

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