[freetds] DBD::ODBC::st fetchrow_hashref failed: [unixODBC][FreeTDS][SQL Server]Data truncated (SQL-01004)

Buurman, H.A. (Herbert) h.a.buurman at interlogica.nl
Mon May 18 07:46:50 EDT 2009


> -----Original Message-----
> On Saturday, 16 May, 2009 22:05, James K. Lowden wrote:
> 
> Buurman, H.A. (Herbert) wrote:
> > After upgrading to freeTDS 0.82-5 (debian testing), I'm suddenly
> > getting these errors when fetching datarows from a prepared 
> > and executed query on an MSSQL server (v 9.0.2047) that I didn't 
> > get before.
> > I Couldn't find anything about this in the archives
> > (no, this is not related to the LongReadLen and LongTruncOK 
> > db-connect options).
> > DBI		version 1.607
> > DBI::DBD	version 12.010405
> > DBD::ODBC	version 1.21
> > unixodbc	version 2.2.11-16+b1
> > TDS version used (in freetds.conf): 8.0
> > text size (in freetds.conf): 64512
> 
> I would do two things.  First, try to simplify the query and 
> isolate the column causing the problem. 

And so I've done...funky thing is, it turns out that it's not caused
by the query itself but by what happens before. There are 2 queries
involved here. One to get a list of identifiers from a table, and then
another that gets additional info from that same table for each
identifier in the list. I've shrunk it all down to the example below
(Database connection code left out):

my $ExampleQuery = $dbh->prepare("SELECT Identifier FROM Table WHERE
Identifier = ?");
my $Record_ref;
my $Identifiers_ref = $dbh->selectcol_arrayref("SELECT TOP 10 Identifier 
FROM Table WHERE SomeCondition > 0");
foreach (@{$Identifiers_ref}) {
    $ExampleQuery->execute($_);
    if ($Record_ref = $ExampleQuery->fetchrow_hashref()) {
        foreach (keys %{$Record_ref}) { print("$_ => $Record_ref->{$_}, "); }
        print("\n");
    } else {
        print("Error fetching data for item [$_]\n");
    }
    $ExampleQuery->finish();
}

The Above code results in 
DBD::ODBC::st fetchrow_hashref failed: [unixODBC][FreeTDS][SQL Server]
Data truncated (SQL-01004) at ./demoscript.pl line <line_with_fetchrow_hashref>.

Where replacing the line starting with "my $Identifiers_ref" with this:
my $Identifiers_ref = [ "id01", "id01" ];

makes it all work as it should.

Is it something I did, or should I file a bugreport somewhere?
The Debian package tdsodbc 0.63-3.2 did not have this issue (whereas 0.82-5 does).

Best regards,
H. Buurman

(Be warned: automatically attached html-coded corporate signature starts here)

<html>
<body>
<pre style="font-size: 7.5pt; font-family: Arial; color: black; font-style: italic; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; margin-bottom: .0001pt">&nbsp;<pre style="font-size: 7.5pt; font-family: Arial; color: black; font-style: italic; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; margin-bottom: .0001pt"><span lang="nl"><font color="#C0C0C0" style="font-size: 7pt" face="Arial"><i><b><u>Disclaimer</u>

Deze e-mail is verzonden door Interlogica B.V. De inhoud en eventuele bijlagen zijn vertrouwelijk en uitsluitend bestemd voor de
geadresseerde. Interlogica B.V. verzoekt bij onjuiste adressering direct contact met haar op te nemen (<a href="mailto:info at interlogica.nl">mailto:info at interlogica.nl</a>),
de naam van de afzender en de geadresseerde aan haar op te geven en vervolgens dit e-mailbericht uit uw systeem te verwijderen.
Interlogica B.V. is niet aansprakelijk voor het overbrengen van virussen en het is uw verantwoordelijkheid deze e-mail (en eventuele
bijlagen) te controleren. Interlogica B.V. (geregistreerd bij het Handelsregister nr. 08067177) is gevestigd te Ecofactorij 20,
NL-7325 WC Apeldoorn.

This is an e-mail from Interlogica B.V. Its contents and any attachments are confidential and intended solely for the use of the
individual to whom it is addressed. If received in error, please contact Interlogica B.V. (<a href="mailto:info at interlogica.nl">mailto:info at interlogica.nl</a>)
quoting the name of the sender and the addressee, then delete it from your system. Please note that Interlogica B.V. does not accept any
responsibility for viruses and it is your responsibility to scan the email and any attachments (if any). Interlogica B.V. 
(registered with the Chamber of Commerce no. 08067177) is resident at Ecofactorij 20, NL-7325 WC Apeldoorn, The Netherlands.
</b></i>
</font>
<p>&nbsp;</p>
</body>
</html>



More information about the FreeTDS mailing list