Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
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

> $   
> Connection OK to Server
> INPUT parameter is a ref but not a CODE ref at 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);

sub getdata {
   return $dbh->ct_fetch;


Michael Peppler                              Data Migrations, Inc.             
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions -