Skip to Content.
Sympa Menu

freetds - [freetds] FreeTDS, Perl, unicode

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Johnson <serversage AT gmail.com>
  • To: FreeTDS AT lists.ibiblio.org
  • Subject: [freetds] FreeTDS, Perl, unicode
  • Date: Mon, 11 Mar 2013 01:28:59 -0700

Hey Folks -

First off, all my details:

Microsoft SQL Server 2008
Ubuntu 12.04
Perl 5.14.2
DBI 1.616
DBD::ODBC 1.43
FreeTDS 0.91-1
unixODBC 2.2.14

I'm using perl/freetds to connect to a Microsoft SQL server at a remote location. The server is not controlled by me, I have read-only access, nothing more. My perl script connects using:

DBI->connect ("dbi:ODBC:DRIVER={FreeTDS};Server=IPOFHOST;Port=1433;DATABASE=NAMEOFDATABASE;OpenMode=0" );

I'm able to connect, and run queries on some tables. But, there is a table that has some NCHAR columns. One of the columns contains some unicode. When I select from that table I get the following error:

DBD::ODBC::st fetchrow_hashref failed: st_fetch/SQLFetch (long truncated DBI attribute LongTruncOk not set and/or LongReadLen too small) (SQL-HY000)

This is using TDSVER=7.0 and I have also tried TDSVER=8.0. Anything lower than 7.0 fails to connect. The table only has 3 rows in it, so I'm able to easily figure out that the row causing the problem has the following without the quotes:

"CPT ® "

Setting LongTruncOK lets me run queries, but that is not an acceptable solution in this case. I've tried setting LongReadLen to something insanely huge - 500000000 - but that failed with the same error.

I've given tsql a try, both with TDSVER=7.0 and 8.0, and while it returns the rows from the table, the row with the unicode character has some funky characters and doesn't appear totally correct.

I'm stumped, and have never really had luck with unicode/freetds/perl, so I thought I'd reach out and pray that some graceful person would have mercy on me. :)

Thanks folks!

-Brian




Archive powered by MHonArc 2.6.24.

Top of Page