Click here to get back home

Sybase::Xfer may not see delimiter?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Sybase::Xfer may not see delimiter? Keith 09-14-2006
Posted by Keith on September 14, 2006, 3:52 pm
Please log in for more thread options


'not sure if anyone can help here; I'm cross-posting to both a Perl & a
Sybase forum ....

I've used Sybase::Xfer (a Perl 5.8.6 module) to transfer data between
ASE 12.5.3 databases for months, in slightly varied applications with
excellent results.

Now I'd like to write a script which very simply bcp's data into a
table from a delimited file (which one would presume to be easier, or
so I'd have thought), and the module seems to ignore my delimiter for
some reason. The file in question is perfectly loadable by native
(Linux) bcp itself, but for a variety of reasons I'd rather do it using
this Perl module.

The snippet:
my %switches = (
# ...
-from_file=>$bcpDataFile,
-from_file_delimiter=>'|',
# ...
);

my $h = Sybase::Xfer->new( %switches );
my %status = $h->xfer(-return=>"HASH");
die "xref failed. $status\n" unless $status;


The error:
#recnum=1, reason=number of columns in data record does not match
number of columns in target table

My table looks like: ( colA varchar(30), colB float )

My data file looks like: StringWithNoPipe |1.234

.......................................
MoStringsSansPipes|4.567

I notice that bcp wants both a column delimiter as well as a row
delimiter, while Sybase::Xfer seems to take just one; I'm not sure if
that's confusing it? (The file is newline delimited). I'm not even
sure the delimiter is the issue, and have tried tab (\t) rather than
pipe, various methods of quoting it (single quotes, double quotes,
variable interpolation, backslashed char, regexp, etc.

Any help greatly appreciated...

Keith Wingate / DBA


Posted by hatfieldrc@gmail.com on September 15, 2006, 11:17 am
Please log in for more thread options


Just to ask a simple question - have you examined your varchar(30)
variable for any occurrance of "|" within it? This would throw things
off in terms of field counts.
rch


Keith wrote:
> 'not sure if anyone can help here; I'm cross-posting to both a Perl & a
> Sybase forum ....
>
> I've used Sybase::Xfer (a Perl 5.8.6 module) to transfer data between
> ASE 12.5.3 databases for months, in slightly varied applications with
> excellent results.
>
> Now I'd like to write a script which very simply bcp's data into a
> table from a delimited file (which one would presume to be easier, or
> so I'd have thought), and the module seems to ignore my delimiter for
> some reason. The file in question is perfectly loadable by native
> (Linux) bcp itself, but for a variety of reasons I'd rather do it using
> this Perl module.
>
> The snippet:
> my %switches = (
> # ...
> -from_file=>$bcpDataFile,
> -from_file_delimiter=>'|',
> # ...
> );
>
> my $h = Sybase::Xfer->new( %switches );
> my %status = $h->xfer(-return=>"HASH");
> die "xref failed. $status\n" unless $status;
>
>
> The error:
> #recnum=1, reason=number of columns in data record does not match
> number of columns in target table
>
> My table looks like: ( colA varchar(30), colB float )
>
> My data file looks like: StringWithNoPipe |1.234
>
> .......................................
> MoStringsSansPipes|4.567
>
> I notice that bcp wants both a column delimiter as well as a row
> delimiter, while Sybase::Xfer seems to take just one; I'm not sure if
> that's confusing it? (The file is newline delimited). I'm not even
> sure the delimiter is the issue, and have tried tab (\t) rather than
> pipe, various methods of quoting it (single quotes, double quotes,
> variable interpolation, backslashed char, regexp, etc.
>
> Any help greatly appreciated...
>
> Keith Wingate / DBA


Posted by Keith on September 18, 2006, 8:43 am
Please log in for more thread options


I wish it were that simple. :-). I can load the file w/ bcp, so I'm
sure the file itself
is OK. I did double-check and the only delimiters are the ones which
should be
there.

Thanks, though.


hatfieldrc@gmail.com wrote:
> Just to ask a simple question - have you examined your varchar(30)
> variable for any occurrance of "|" within it? This would throw things
> off in terms of field counts.
> rch
>
>
> Keith wrote:
> > 'not sure if anyone can help here; I'm cross-posting to both a Perl & a
> > Sybase forum ....
> >
> > I've used Sybase::Xfer (a Perl 5.8.6 module) to transfer data between
> > ASE 12.5.3 databases for months, in slightly varied applications with
> > excellent results.
> >
> > Now I'd like to write a script which very simply bcp's data into a
> > table from a delimited file (which one would presume to be easier, or
> > so I'd have thought), and the module seems to ignore my delimiter for
> > some reason. The file in question is perfectly loadable by native
> > (Linux) bcp itself, but for a variety of reasons I'd rather do it using
> > this Perl module.
> >
> > The snippet:
> > my %switches = (
> > # ...
> > -from_file=>$bcpDataFile,
> > -from_file_delimiter=>'|',
> > # ...
> > );
> >
> > my $h = Sybase::Xfer->new( %switches );
> > my %status = $h->xfer(-return=>"HASH");
> > die "xref failed. $status\n" unless $status;
> >
> >
> > The error:
> > #recnum=1, reason=number of columns in data record does not match
> > number of columns in target table
> >
> > My table looks like: ( colA varchar(30), colB float )
> >
> > My data file looks like: StringWithNoPipe |1.234
> >
> > .......................................
> > MoStringsSansPipes|4.567
> >
> > I notice that bcp wants both a column delimiter as well as a row
> > delimiter, while Sybase::Xfer seems to take just one; I'm not sure if
> > that's confusing it? (The file is newline delimited). I'm not even
> > sure the delimiter is the issue, and have tried tab (\t) rather than
> > pipe, various methods of quoting it (single quotes, double quotes,
> > variable interpolation, backslashed char, regexp, etc.
> >
> > Any help greatly appreciated...
> >
> > Keith Wingate / DBA


Posted by Keith on September 18, 2006, 8:43 am
Please log in for more thread options


I wish it were that simple. :-). I can load the file w/ bcp, so I'm
sure the file itself
is OK. I did double-check and the only delimiters are the ones which
should be
there.

Thanks, though.


hatfieldrc@gmail.com wrote:
> Just to ask a simple question - have you examined your varchar(30)
> variable for any occurrance of "|" within it? This would throw things
> off in terms of field counts.
> rch
>
>
> Keith wrote:
> > 'not sure if anyone can help here; I'm cross-posting to both a Perl & a
> > Sybase forum ....
> >
> > I've used Sybase::Xfer (a Perl 5.8.6 module) to transfer data between
> > ASE 12.5.3 databases for months, in slightly varied applications with
> > excellent results.
> >
> > Now I'd like to write a script which very simply bcp's data into a
> > table from a delimited file (which one would presume to be easier, or
> > so I'd have thought), and the module seems to ignore my delimiter for
> > some reason. The file in question is perfectly loadable by native
> > (Linux) bcp itself, but for a variety of reasons I'd rather do it using
> > this Perl module.
> >
> > The snippet:
> > my %switches = (
> > # ...
> > -from_file=>$bcpDataFile,
> > -from_file_delimiter=>'|',
> > # ...
> > );
> >
> > my $h = Sybase::Xfer->new( %switches );
> > my %status = $h->xfer(-return=>"HASH");
> > die "xref failed. $status\n" unless $status;
> >
> >
> > The error:
> > #recnum=1, reason=number of columns in data record does not match
> > number of columns in target table
> >
> > My table looks like: ( colA varchar(30), colB float )
> >
> > My data file looks like: StringWithNoPipe |1.234
> >
> > .......................................
> > MoStringsSansPipes|4.567
> >
> > I notice that bcp wants both a column delimiter as well as a row
> > delimiter, while Sybase::Xfer seems to take just one; I'm not sure if
> > that's confusing it? (The file is newline delimited). I'm not even
> > sure the delimiter is the issue, and have tried tab (\t) rather than
> > pipe, various methods of quoting it (single quotes, double quotes,
> > variable interpolation, backslashed char, regexp, etc.
> >
> > Any help greatly appreciated...
> >
> > Keith Wingate / DBA


Similar ThreadsPosted
ASE 12.5 UTF-8 issues with Sybase::DBLib April 5, 2006, 5:05 am
Error installing DBD::Sybase September 11, 2007, 12:39 pm
SQL Server triggers (dbi:ODBC vs dbi:Sybase) August 12, 2004, 9:15 am
Problems installing DBD::Sybase on Mac OS X with SQLAnywhere9 May 4, 2005, 5:11 pm
Sybase Stored Procedure issue June 14, 2006, 12:27 pm
Sybase Simple gmake test unresolved external - HP/UX March 1, 2005, 8:58 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap