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: bcp via Sybase::DBlib - seg faults and error catching
Date: Sep 12 2002 10:02AM

On Wed, 2002-09-11 at 08:22, Peter Sinnott wrote:
> When I call bcp_sendrow with an oversized field ( sending 20 chars to a
> char(10) ) $DB_ERROR gets set but FAILURE is not returned. Is there any
> way to upgrade this warning to an error or to role back the sendrow?

I'll have to look.

> Prior to fetching the data I call bcp_meminit with the number of columns
> I expect(say 3). If I call bcp_sendrow with an array ref with 5 elements the
> script bombs out with : 
> More columns passed to bcp_sendrow than were allocated with bcp_meminit
> at /VBB/ line 226,  line 3

OK - that's a call to fatal() (I think) in the C portion of the DBlib
module. It could be toned down to a warning, I suppose, or you could
wrap the call in an eval.

> With 4 the sendrow goes ok and the first 3 elements get inserted. I can't
> see any indication anything has gone wrong but when I call bcp_done I
> get a seg fault.

That's a bug - probably an off-by-one error in the C code.

> Finally,when I call bcp_batch and it bombs because I'm inserting a
> duplicate row in a table with a unique index is there any simple way to
> work out which row is causing the problem? There will probably be
> situations where I want an all or nothing bcp so I can't use a batch
> size of one to work out the problem row. Whenever the angry men with
> beepers get called I'm sure they would like to know which row is causing
> the problem.

This is something that has eluded me as well. I'm not sure that this
information is available via the API. I have a feeling that similar
problems occur when you use Sybase's bcp binary, so it may be an
inherent problem with the way bcp works (although I'd have to go back
and look at bcp in detail again to be sure).

As an aside - I am still on vacation in Europe, so don't expect any
actual fixes for another couple of weeks.

Michael Peppler / / / ZetaTools, Inc /
ZetaTools: Call perl functions as Sybase stored procedures!