CLONE -Long VARCHAR parameters in where clause reported as "string truncation"
------------------------------------------------------------------------------

                 Key: DNET-256
                 URL: http://tracker.firebirdsql.org/browse/DNET-256
             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: A. Murat Ozdemiray
            Assignee: Jiri Cincura
            Priority: Critical
             Fix For: 2.5.0 Beta 1


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

        

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to