http://qs321.pair.com?node_id=663835

millsperl has asked for the wisdom of the Perl Monks concerning the following question:

An existing perl script was working fine. However on a new linux server the text that is retrieved from a varchar 5000 column is being truncated. Apparently the Perl version is the same. When I did some searching I found the "LongReadLen" attribute. Where is this set so that it would be picked up by all the perl scripts? I tried to set it within the perl script to see if that would help and it failed, i.e.: "Setting of CS_OPT_TEXTSIZE failed at line 44." Line 44 is the line where the LongReadLen is set.
# --- connect to database ---/ $dbh = DBI->connect("DBI:Sybase:server=$dbserver", $user, $passwd); $dbh->do("use $dbname"); $dbh->{LongReadLen} = 6000;
I would appreciate any assistance.

Replies are listed 'Best First'.
Re: Text retrieved from database column being truncated
by mpeppler (Vicar) on Jan 24, 2008 at 07:13 UTC
    You don't say, but I'm guessing that you are using FreeTDS and an MS-SQL data server.

    If that is correct then DBD::Sybase's technique for setting LongReadLen (which involves calling ct_options() with the CS_OPT_TEXTSIZE attribute in the ClientLibrary API) does not work.

    The work-around:

    $dbh-do("set textsize <some_size_in_bytes");
    Note that this problem is at the very least hinted at in the DBD::Sybase man page.

    Michael

      Hi Michael, Yes, you are correct that the perl script is connecting to a MS-SQL database server. The strange thing is that on both linux servers the perl script is the same and even the database table is the exact same table. On the original server I can see the full contents of the database column from the perl script output running on that server. However on the new linux server running the same perl script against the same table the contents of the varchar 5000 column are being truncated. I tried your work around. Although it didn't complain, the results were the same, i.e. the column was still truncated. There seems to be some setting at server level or something that is affecting the size of the column contents that can be retrieved by perl script/s.
        Are you using the exact same version of FreeTDS?

        Is it configured in the same way?

        Keep in mind that wide varchar() support depends on the TDS protocol version that is supported. IIRC this can be set in the freetds.conf file, and should be set to 7 or 8 to get wide varchar() support.

        Michael

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Text retrieved from database column being truncated
by igelkott (Priest) on Jan 23, 2008 at 17:41 UTC
    Set LongReadLen immediately after the connect statement.
      Unfortunately, the only difference now is that it is failing on an earlier line number.
        If it still fails, it might just be that it's your connect that's actually failing. This "new linux server" might not have connect privileges.

        Test your connect statement like:

        $dbh = DBI->connect("DBI:Sybase:$dbserver", $user, $passwd) || die "Can't connect to $dbserver due to $DBI::errstr";