Perl Not Reading Full Values from Database

亡梦爱人 提交于 2019-12-25 04:32:18

问题


I am currently using the DBI module to connect to my MSSQL Database to pull some data from a table.

The row I am trying to pull contains a lot of text (it is of type ntext and can contain up to 6Mb of text).

My query is a very simple one at the moment:

my $sql = "SELECT TOP 1 [reportRow] from UsageReport";

And I also have LongTruncOk enabled for the Database options.

After I execute the query, I want to display the rows.

while ( my @row = $sth->fetchrow_array ) {
   print "@row\n";
}

Unfortunately it displays the data in a very weird manner with spaces in between every character and it only retrieves the first 40 characters.

< r e p o r t > < r e p o r t h e a d e r > < m o n t h > O c t o b e r   2 0

If I use File::Slurp to output @row to a file, it displays as

Is there a reason the data is being cut off and is being displayed weird?

Edit: How would I convert UTF16 into a format that doesn't insert spaces between characters?


回答1:


You need to set LongReadLen in addition to LongTruncOk. You've told DBI it's ok to cut off long results from the DB, and now you need to tell it how long of a string you're willing to accept.



来源:https://stackoverflow.com/questions/31035931/perl-not-reading-full-values-from-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!