String truncation exception from comparing '12345' to Char(3) '123' using Firebird

Thread is closed for posting
1 posts, 0 answers
  1. Petteri
    Petteri avatar
    9 posts
    Member since:
    Jan 2015

    Posted 12 Jun 2015 Link to this post

    I'm using this LINQ to check if input is valid

    Kansalaisuuskoodis.Any(k => k.Kansalaisuuskoodi == input)
    Where 'input' is a string and Kansalaisuuskoodi is a string mapped to a char(3) column (model generated from a Firebird database).

    This call will fail if the length of input string is not exactly 3 characters:


    Telerik.OpenAccess.Exceptions.DataStoreException: Count(*) query failed: Telerik.OpenAccess.RT.sql.SQLException: arithmetic exception, numeric overflow, or string truncation
    string right truncation
    at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery(Nullable`1 commandTimeout)
    at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery(Nullable`1 commandTimeout)
    at OpenAccessRuntime.Relational.RelationalStorageManager.executeCount(RelationalCompiledQuery cq, QueryParameters parameters)
    SELECT COUNT(1) FROM ( SELECT a."Kansalaisuuskoodi" AS COL1, a."Kayttotiedot" AS COL2, a."LUONTIAIKA" AS COL3, a."MUUTOSAIKA" AS COL4, a."Maa" AS COL5 FROM "Kansalaisuus" a WHERE a."Kansalaisuuskoodi" = ? ) AS TMP_COUNT

    This seems odd to me, since Firebird sql is working as expcted with such a query (comparing char(3) column with a varchar(5) input).

    So currently I compare the lenght of the input before checking the database, but this seems like something should not be needed. 
    Any idea what could cause this exception?

Back to Top