develooper Front page | perl.dbi.users | Postings from February 2008

Re: Perl and ODBC on Win32

From:
Martin Evans
Date:
February 12, 2008 01:01
Subject:
Re: Perl and ODBC on Win32
doktorZee wrote:
> Salutations all, I'm working on a Perl script to migrate data through
> ODBC from a series of tables on one DBMS to a single table on a
> separate DBMS, with access connections defined in the ODBC Sources
> Win32 control panel applet.
> 
> It works fine on my computer and a co-worker's computer, which both
> run Windows XP. However, on the client's computer which runs Windows
> 2000, it gives an ODBC error. All three setups use MS SQL 2000 and
> ActiveState Perl 5.8.8.  The operating system is the only difference,
> and why it could be the source of the problem I don't know.
> 
> On Windows 2000 I get:
> DBD:ODBC::st fetchrow_arrayref failed: [Microsoft][ODBC SQL Server
> Driver] String data, right truncation (SQL-01004)(DBD: st_fetch/
> SQLFetch (long truncated DBI attribute LongTruncOK not set and/or
> LongReadLen too small) err=-1)
> 
> I searched online for the error and all I could find was that this
> should work:
> $dbh->{LongReadLen} = 16384;
> $dbh->{LongTruncOk} = 1;
> 
> I tried this, and it does not impair the functionality on the XP
> systems but it does not resolve the problem. I also did some analysis
> on the data, and found that the source DB has data that is 100 or 200
> characters (nvarchar) and the target DB takes 255 characters of
> nvarchar. The largest piece of data is 80 characters, so there really
> shouldn't be any truncation problem to begin with.  Any help would be
> greatly appreciated, as its been weeks of no leads or success and I'm
> going insane.  Thanks again.
> 
> 
Can you send me DBI_TRACE=15 output from running your script on the 
broken machine. The only way to get data truncated error on a fetch is 
if the buffer DBD::ODBC supplies is too small. If you really have set 
LongTruncOk then the error should be ignored by DBD::ODBC.

It would also be useful to know:

DBI version
DBD::ODBC version
ODBC Driver Manager version (see your DataSources in control panel)
version of the ODBC driver you are using (as above)

Martin
-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com



Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About