On 22/06/12 03:51, [email protected] wrote:
Hello,I would appreciate your help with the following question. I'm using DBD::ODBC to connect to a pervasive database. There is a column in the table that is defined as LONGVARCHAR - 31999 bytes. The fetch statement on the column fails with the following error [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Data truncated column 1. (SQL-01004) [Pervasive][ODBC Client Interface]Data truncated column 1. (SQL-01004) I set LongReadLen to 31999 and LongTruncOk to False to resolve the issue. I don't get an error now, but the data is getting truncated to 80 characters. Is there an issue with the Pervasive ODBC driver not supporting LongReadLen? my $sql_col1; $dbh->{LongReadLen} = 31999; $dbh->{LongTruncOk} = False; print $dbh->{LongReadLen}; if ( !$sth->bind_columns( undef, \$sql_col1 ) ) { print $LOG_FH "Error encountered when binding columns in SQL statement $sql_to_run - $DBI::errstr\n"; $rc = 1; return ( $rc, \@db_records ); } my $reccount = 0; while ( $sth->fetch ) { #Remove trailing spaces $sql_col1 =~ s/\s+$//; $db_records[$reccount] = $sql_col1; $reccount++; } Thanks, Saraswathi
Neither LongReadlen or LongTrunkOk are features of the ODBC driver - they are DBI/DBD attributes. The above code is not sufficient to really tell what you are doing and you cannot expect to set LongReadLen/LongTrunkOk on a connection handle after the statement was created and have it take affect in the statement. Cut this down to a small example and run it with DBD_VERBOSE=DBD=x.log and send the log. For DBD tracing you'll need a recent DBI and DBD::ODBC so if you are not in that position substitute 15 for DBD. BTW, DBI has an attribute to ChopBlanks for you for char columns. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com
