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: Using files to load database objects
Date: Jul 12 1999 9:56PM

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