Long VARCHAR parameters in where clause reported as "string truncation"
-----------------------------------------------------------------------
Key: DNET-124
URL: http://tracker.firebirdsql.org/browse/DNET-124
Project: .NET Data provider
Issue Type: Bug
Components: ADO.NET Provider
Affects Versions: 2.0.1
Environment: WIndows XP, firebird engine 2.01, visual studio 2005
Reporter: Stéphane Claret
Assignee: Carlos Guzman Alvarez
Priority: Critical
Hello,
Let's consider this simple table :
-------------------------------------------
CREATE TABLE DEVISE (
CODE_DEVISE Char(3) NOT NULL COLLATE ES_ES_CI_AI,
NOM_DEVISE Varchar(20) NOT NULL COLLATE ES_ES_CI_AI,
CONSTRAINT PK_DEVISE PRIMARY KEY (CODE_DEVISE)
);
INSERT INTO DEVISE (code_devise, nom_devise) VALUES (chg, "test");
-------------------------------------------
Now if you try to execute the following code in a c# program
--------------------------------------------
FbCommand fb = conex.CreateCommand();
fb.CommandText = "SELECT * FROM DEVISE WHERE DEVISE.CODE_DEVISE LIKE 'chg%'";
FbDataReader reader = fb.ExecuteReader();
reader.Read();
--------------------------------------------
It works perfectly, (1 row returned )
But now, if you try to execute the same sql statement but by using a parameter
in the WHERE Clause instead of a constant value :
--------------------------------------------
FbCommand fb = conex.CreateCommand();
fb.CommandText = "SELECT * FROM DEVISE WHERE DEVISE.CODE_DEVISE LIKE
@devise1";
fb.Parameters.Add("@devise1", "chg%");
FbDataReader reader = fb.ExecuteReader();
reader.Read();
--------------------------------------------
fb.ExecuteReader raises a numeric overflow / String truncation exception, most
probably because the length of "chg%" (4 chars) exceeds the size of the
code_devise column ( CHAR(3) ).
I think that the lenght of string parameters should not be so strictly enforced
when they are used in a WHERE clause because it produces unwanted behavior and
prevent execution of statements which are actually correct.
Regards
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider