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::BCP - Has OUT been implemented yet?
Date: Mar 21 2003 4:47PM

On Fri, 2003-03-21 at 03:53, wrote:
> Michael,
> I was searching CPAN and came across the Syabse::BCP perl module that you wrote. 
> I am writing a simple script to archive any table in any given 
> database for my organisation and when I found your .pm I thought that 
> this was just what I was looking for. Unfortunately I later read in 
> description that the OUT functionality had yet to be implemented. I 
> was wondering whether any progress had been made on this?

I haven't done anything with this at all - mainly because a BCP out is
really just a SELECT without a where clause (or at least Sybase
engineers used to say a few years ago - maybe it has changed today).

Anyway a minimal BCP out operation can be written in a single line:

use Sybase::CTlib;

$dbh = new Sybase::CTlib ...;
open(BCP_FILE, ">the_table.bcp") || die "Oops!";

$dbh->ct_sql("select * from the_table", sub {local $" = "\t"; print
BCP_FILE "@_\n"; });

which will create a tab-separated BCP file...

That said you may get much better results by using the bcp binary, but
generating the bcp commands on the fly in a perl script.

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