[SOLVED] Uniface related or not, that's the question: ODBC-error 22018

Author: i2stiller@gmx.de (istiller)

Hi Freaks At customer site, we got a strange ODBC error (UnifAce 9.6 against SQL-Server 2012) 22018 "Invalid character value for cast specification" We experienced this error (by now) only in one table, which result in a 9020 data fetch error To find any clue, what's going on, I did already:

  • Truncate table
  • Drop and create table
  • use different UnifAce Driver Version (U4.0 U5.0)
  • Analyse ODBC-Logs
  • ...

I'm going crazy with this issue.

  • Could this be a UnifAce Problem?
  • Could this be a ODBC Problem?
  • Could this be a DBMS error?
  • ...?

Any idea ? Ingo PS: The same customer do habe another Server, which works  

                             working             not working
SQL-Server 2012     11.0.3000          11.0.6020
ODBC                     6.2.9200.16384  6.3.9600.17415
Windows  2012 R2   6.2.9200            6.3.9600


  1. Hi Ingo, I did not met any similar situation but as quick brainstorming: the issue is related to casting...casting is converting characters from one datatype to another... We are in a transition period from when Unicode became the new standard. is there any possibility installation character sets are involved? Gianni P.S. My bet is: go back with ODBC driver.

    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  2. What is the default collation for the two servers?  has the collation of that table/field somehow been altered?  Is there a particular row in the table which triggers the error or is it all rows? 

    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  3. Hallo Ingo, are you getting this error when trying to store an entity/table with numeric fields ? There is a known issue with SQL Server when trying to store uninitialized numerics.  Under specific circumstances it's not possible to store an empty numeric field that's using interface shorthand code N.  Storing results in the error message:

    "22018 [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification"
    The workaround is to initialize any empty numeric field with a value prior to storing.
    Hope this helps

    Author: StefanH-US (stefan.hirsch@uniface.com)
  4. Problem is solved Don't what was the sticky bit, but after a few tries and resinstall the ODBC, there is no more error. Thanks to all for there help Ingo

    Author: istiller (i2stiller@gmx.de)