[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
Fri May 15 05:16:08 EDT 2009


Hello,

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

Any help would be appreciated :)

Query is as follows (fieldnames have been obfuscated to protect the innocent :))

SELECT
  CASE WHEN Field1 IS NULL THEN CAST(Field2 AS NVARCHAR(30)) ELSE CAST(Field1 AS NVARCHAR(30)) END AS Name1,
  CASE WHEN Field1b IS NULL THEN CAST(Field2b AS NVARCHAR(30)) ELSE CAST(Field1b AS NVARCHAR(30)) END AS Name1b,
  CAST(Field3 AS NVARCHAR(5)) AS Name3,
  CAST(Field4 AS NVARCHAR(11)) AS Name4,
  Field5 AS Name5,
  CAST(Field6 AS NVARCHAR(5)) AS Name6,
  Field7 AS Name7,
  Field8 AS Name8,
  Field9 AS Name9,
  CAST(Field10 AS NVARCHAR(4)) AS Name10,
  Field11 AS Name11,
  Field12 AS Name12,
  Field13 AS Name13,
  Field13 AS Name14,
  Field14 AS Name15,
  1 AS Name16,
  Field15 AS Name17,
  'N' AS Name18,
  0 AS Name19,
  CAST(Field16 AS NVARCHAR(3)) AS Name20,
  Field5 AS Name21,
  1 AS Name22,
  Field17 AS Name23,
  CAST(Field18 AS NVARCHAR(8)) AS Name24,
  1 AS Name25,
  0 AS Name26,
  Field19 AS Name27,
  Field20 AS Name28,
  1 AS Name29,
  Field21 AS Name30,
  Field21 / 1.19 AS Name31
FROM T1 with(nolock)
  JOIN T2 with(nolock) ON T1.SomeField1 = T2.SomeField2
  JOIN T3 with(nolock) ON T1.SomeField3 = T3.SomeField4
  JOIN T4 with(nolock) ON T1.SomeField5 = T4.SomeField6
  LEFT JOIN T5 with(nolock) ON T1.SomeField7 = T5.SomeField8 AND T5.SomeField9 = 2
WHERE
  T1.Field5 = ?

The Various casts to NVARCHAR(X) are to handle NVARCHAR(MAX)-types which caused
errors in the past. It appears some fields have been changed from MAX to a more
reasonable size since the query was first created, so some casts are not required
anymore, but are still present.

The types of the various fields are:
Field1	NVARCHAR(MAX)
Field1b	NVARCHAR(MAX)
Field2	NVARCHAR(100)
Field2b	NVARCHAR(30)
Field3	NVARCHAR(30)
Field4	NVARCHAR(11)
Field5	NVARCHAR(20)
Field6	NVARCHAR(10)
Field7	NVARCHAR(15)
Field8	NVARCHAR(16)
Field9	NVARCHAR(17)
Field10	NVARCHAR(10)
Field11	Numeric(19,6)
Field12	Numeric(19,6)
Field13	Numeric(19,6)
Field14	Numeric(19,6)
Field15	NVARCHAR(5)
Field16	NVARCHAR(20)
Field17	SMALLINT
Field18	NVARCHAR(8)
Field19	Numeric(19,6)
Field20	Numeric(19,6)
Field21	Numeric(19,6)

Best regards,
H. Buurman

<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