Tony Esposito wrote:
> ERROR:
> sth->fetchrow_array fails with ODBC (DBD::ODBC) connection to SQL Server but
> works fine with ORACLE using DBDOracle. See error below ...
>
> DBD::ODBC::st fetchrow_array failed: [Microsoft][ODBC SQL Server
> Driver]String d
> ata, right truncation (SQL-01004) at create_data_dump.pl line 267, <CFGFILE>
> lin
> e 2.
> DBD::ODBC::st fetchrow_array failed: [Microsoft][ODBC SQL Server
> Driver]String d
> ata, right truncation (SQL-01004) at create_data_dump.pl line 267, <CFGFILE>
> lin
> e 2.
>
> CODE: (fetches a table row then writes each column of data separated by
> delimiter)
>
> while ( @table_row = $sth->fetchrow_array ) {
> my $count = @table_row; # get number of columns
> for ( my $counter = 0; $counter < $count; $counter = $counter + 1 ) {
> if ( $counter == $count - 1 ) { # if last col then no field delimiter
> if ( defined($table_row[$counter]) ) {
> print DATFILE "\"$table_row[$counter]\"";
> }
> } elsif ( !defined($table_row[$counter]) ) { # if no col data then
> only field delimiter
> print DATFILE "$field_term";
> } else { # otherwise, output col
> and delimiter
> print DATFILE "\"$table_row[$counter]\"$field_term";
> }
> } # end of for loop
> print DATFILE "\n"; # when all cols outputted, print newline
> } # end of inner while loop
> #
> # If verbose mode 'ON', then print to screen output info
> #
> if ( defined $opt{v} ) {
> print STDOUT "Done.\n";
> }
> close (DATFILE);
> } # end of outer while loop
>
> Has anyone seen this error before?
You have shown the wrong part of your code - the relevant section precedes this
part. But I suggest that you experiment with the value of $dbh->{LongReadLen}.
Set it after connecting to the the database and before preparing the statement
handle. Start with a value of about 80 like this
$dbh->{LongReadLen} = 80;
and adjust it so that it is as small as possible but large enough to prevent the
error message appearing.
HTH,
Rob
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/