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

Hello Friends,

I am using FreeTDS and DBI to talk from my linux box to a MSSQL Server 7 on a Win2k box. It has mostly been working (I can insert & select varchars of up to 8000 bytes and insert text blobs of over 10k), however, when I try to retrieve a text block of just over 10k, I get "Out of memory!" from perl. Now I could understand if this was a very large block of text, but it really isn't. Also, there is only one row in the table and only one column which contains this block of text. Does anyone have any suggestions on why this might be happening? My linux box is no slouch: dual 850Mhz PIII with 2G ram and gobs of /tmp and /swp available. I am using Perl 5.6.1.

Here is my test code:

#!/usr/local/bin/perl -w use DBI; use strict; $ENV{'SYBASE'} = '/usr/local/freetds'; $ENV{'TDSVER'} = 70; my $server = "gene"; my $db = "ragedb"; my $user = "sqluser"; my $passwd = "sqluser"; my $dbh = DBI->connect("dbi:Sybase:server=$server;database=$db",$user, +$passwd) or die "--$!--\n"; $dbh->{LongReadLen}=25000; #bytes, fails even if I set this to 1000. $dbh->{LongTruncOk}=1; my $sth = $dbh->prepare(" select * from sctemp "); $sth->execute; while(my $data = $sth->fetch) { print "@$data\n"; }
Thanks all,
Scott

Replies are listed 'Best First'.
Re: FreeTDS/DBI
by LD2 (Curate) on Aug 16, 2001 at 23:11 UTC
    scain - you may want to take a look at this email... and try their suggested solution.
      LD2,

      That did it! Thanks, and thanks to you and adamsj for making me aware of dbi-users archive.

      For those keeping score at home, all I did was change the line $dbh->{LongReadLen}=25000; to $dbh->do("set textsize 25000");

      Scott

        If you use FreeTDS 0.53 or later you may insert line
        text size 25000
        into freetds.conf and eliminate
        $dbh->do("set textsize 25000");
        from your source code.

        -- yuriy
Re: FreeTDS/DBI
by adamsj (Hermit) on Aug 16, 2001 at 22:46 UTC
    You might look at the dbi-users archive, as there was discussion on FreeTDS recently. I'm not sure that discussion is relevant, but it's not a bad place to look, or ask.

    adamsj

    They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen