|
|
sybperl-l Archive
Up Prev Next
From: ndronen at technolalia dot com
Subject: Re: Sybase::Blk
Date: Aug 9 2004 4:00PM
On Mon, Aug 09, 2004 at 11:30:05AM -0400, 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
>
> What is that I'm missing here? Is it doable what I'm trying in here?
>
> Thanks for all your help.
>
> #!/usr/local/ActivePerl-5.6/bin/perl
Your getdata($dbh) calls $dbh->ct_sql(), which returns $data. $data
in this case is a ref of some sort, but not a code ref. It is as though
you're doing
$bcp->config(INPUT => $thing_returned_by_ct_sql_select, . . . .);
which is not what you want.
You want one of these:
$ perl -wle 'print ref sub {}'
CODE
This *untested* code should address the code ref message you're getting.
###########################################################################
#!/usr/local/ActivePerl-5.6/bin/perl
use warnings;
use strict;
use Sybase::CTlib;
use Sybase::BLK;
my $dbh = Sybase::CTlib->ct_connect('MyUser','password',SYB_UNIX);
if (not defined $dbh) {
# print error and exit
} else {
# print happy message
}
my $bcp = new Sybase::BLK MyUser, 'password', SYB_UNIX;
$bcp->config(
INPUT => sub { $dbh->ct_sql('select * from BatchControl.dbo.a') },
OUTPUT => 'BatchControl.dbo.b',
BATCH_SIZE => 200
);
$bcp->run();
###########################################################################
Regards,
Nicholas
|