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: Sybase::Blk
Date: Aug 9 2004 4:06PM

On Mon, 2004-08-09 at 17:30, Sabherwal, Balvinder (MBS) wrote:
> I have a script as below that I'm trying to execute. I want to do a
> select * from one table and insert into another table without writing
> the data to a flat file. When I execute the script, I get error as
> below

> $ x.pl   
> 
> Connection OK to Server
> 
> INPUT parameter is a ref but not a CODE ref at x.pl line 24

The specific error is that you have:

$bcp->config(INPUT => getdata($dbh),
             OUTPUT => 'BatchControl.dbo.b',
             BATCH_SIZE => 200);

when Sybase::BLK wants you to use

$bcp->config(INPUT => \&getdata($dbh),
             OUTPUT => 'BatchControl.dbo.b',
             BATCH_SIZE => 200);

However, I don't think that chaning that will solve your problem,
because the subroutine passed as the INPUT argument should return a
single row for each call.

I might code it like this (untested, and probably sub-optimal)

my $dbh = Sybase::CTlib->new($user, $pwd, $server1);
my $bcp = Sybase::BLK->new($user, $pwd, $server2);
$dbh->ct_execute("select ... from ... where ...");
$bcp->config(INPUT => \&getdata,
             OUTPUT => 'BatchControl...',
             BATCH_SIZE => 200);
$bcp->run;

sub getdata {
   return $dbh->ct_fetch;
}

__END__

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
mpeppler@peppler.org                       http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html