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: Mix BCP & CT-Lib? Write to bcp via fifo?
Date: Oct 19 2001 11:27PM

Larry Bertolini writes:
 > I have a couple questions about Sybperl and bcp:
 > 
 > 1. can I use the Sybase::BCP functions
 >     from within a Sybase::CTlib program?

Yes.

However, you could also consider trying the latest sybperl patch
release (from http://www.peppler.org/downloads) where I've added some
of the blk_*() routines to the Sybase::CTlib module.

 > 2. Right now, I'm trying to use perl to pipe
 >     data to the bcp process.  Pseudo-code is:
 > 
 >     open input file
 >     start a background bcp process that reads from a fifo file
 >     open fifo file for output
 >     loop:
 >        read record
 >        munge data
 >        write to fifo
 >     endloop
 >     close fifo file
 >     close input file
 > 
 > I'm having weird problems with this approach;
 > bcp dies with the message:
 > 
 >     Unexpected EOF encountered in BCP data-file.
 >     bcp copy in partially failed
 > 
 > Sometimes the program works (processes 500,000 records),
 > but usually it fails; the number of records that it
 > processes is fairly random (a couple hundred, a couple
 > thousand, or several thousand).  I suspect that maybe it's
 > related to perl's file buffering, but I've played with
 > the "$|" variable, and it seems to have no effect (that is
 > to say, it doesn't solve this problem).

You may want to use syswrite() instead of print (or whatever). This
will avoid the buffering.

Michael
-- 
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
mpeppler@peppler.org - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com