Sybase::Xfer may not see delimiter?
Sybase::Xfer may not see delimiter?
am 14.09.2006 21:52:54 von keith
'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{last_error_msg}\n" unless $status{ok};
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
Re: Sybase::Xfer may not see delimiter?
am 15.09.2006 17:17:51 von hatfieldrc
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{last_error_msg}\n" unless $status{ok};
>
>
> 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
Re: Sybase::Xfer may not see delimiter?
am 18.09.2006 14:43:14 von keith
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{last_error_msg}\n" unless $status{ok};
> >
> >
> > 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
Re: Sybase::Xfer may not see delimiter?
am 18.09.2006 14:43:19 von keith
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{last_error_msg}\n" unless $status{ok};
> >
> >
> > 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