|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Ctlib - ct_sql question
Date: Dec 20 2003 1:11AM
On Fri, 2003-12-19 at 16:06, Ravi Pochiraju wrote:
> Hi:
>
> I just started using Sybase::CTLib and have been struggling to do
> this:
> I have a table creation script ( eg. test.tbl that has create table
> statement and create index statements . Every DDL statement has a "go"
> at the end of it.)
>
> I am not been able to successfully use
> $dbh->ct_sql( $tblcreate) assuming that I load the contents of the
> file into this $tblcreate variable.
The "go" is there so that isql or sqsh sends that part of the
command/file to the server for execution. Sybase itself doesn't
understand it.
If you have a file with multiple "go" statements that you want to
execute via ct_sql you need to split the input into sections (i.e. at
each "go"), and execute each section separately.
One way to do this would be to set the $/ variable (perl's record
separator) to "go\n", and then read the file:
open(IN, "the_file.sql") || die "can't open the file: $!";
$/ = "go\n";
while() {
$dbh->ct_sql($_);
}
You obviously need to add error detection, etc. but you get the idea...
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
|