Home > Database > Mysql Tutorial > body text

perl的dbi数据访问odbc读取sqlserver数据被截断的问题

WBOY
Release: 2016-06-07 15:25:11
Original
1605 people have browsed it

select时报错 DBD::ODBC::st fetchrow_arrayref failed: st_fetch/SQLFetch (long truncated DBI attribute LongTruncOk not set and/or LongReadLentoo small) (SQL-HY000) 这种情况加上 $dbh_mssql-{LongTruncOk} = 1; 可以解决。 但是这种方式会 截断 字符

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

这种情况加上
   $dbh_mssql->{LongTruncOk}   = 1;
可以解决。 
但是这种方式会截断字符串。 
我不想截断字符串,想要完整的读取出来。看了下资料 说是可以设置Long的长度。
使用如下:
$dbh_mssql->{LongReadLen}    = 512 *1024;
单独使用时无效。
还是报同样的错误。
$dbh_mssql->{LongReadLen}    = 512 *1024;
 $dbh_mssql->{LongTruncOk}   = 0;
时还是报错

但是跟 $dbh_mssql->{LongTruncOk}   = 1;一起使用时就没问题  只是还是会截断

  还是说 我这里的len长度还不够?  2048*2048还是不行


结果 跟数据类型有关。


$sql_select ="select top 5  [name] , [address] , [developer] , CAST([othercondition] as TEXT), [projectsquare] , [usinglandarea] from new_baseinfo";


注意红色部分。

原来还涉及到数据类型的问题。把被截断的字段改为text。 
然后设置。
      my $dbh_mssql=DBI->connect("dbi:ODBC:$source_name",$source_user_name,$source_user_psd);

   $dbh_mssql->{LongTruncOk}=1;      
   $dbh_mssql->{LongReadLen}    = 1048576*1024;
print "LongReadLen: $dbh_mssql->{LongReadLen}\n";

就可以了



参考资料:

http://blog.csdn.net/aylazhang/article/details/1707745

http://www.freetds.org/userguide/troubleshooting.htm

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!