Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-11048

ODBC Plugin: Strings longer than 254 characters cannot be inserted in varchar column on Informix database

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: P4: Low P4: Low
    • None
    • 4.6.1, 4.6.2, 4.7.0
    • SQL Support
    • None
    • Windows XP
      Informix 10
      Informix ODBC Driver 2.90.0000

      When inserting strings longer than 254 characters into a varchar column using prepared statements, the ODBC driver reports the following error:
      "Illegal attempt to use Text/Byte host variable".

      Looking into the source code of qsql_odbc.cpp (Qt Branch 4.7, 27. 05. 2010), I find that the ODBC plugin reports SQL_LONGVARCHAR for strings longer than 254 characters, and SQL_VARCHAR otherwise ( or SQL_WLONGVARCHAR resp. SQL_WVARCHAR for unicode strings). This is a problem because the Informix ODBC driver maps SQL_LONGVARCHAR to type TEXT (see http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.odbc.doc/odbc69.htm), which causes the mentioned error message.

      In our application we would like to write varchar columns with 255 characters. AFAIK, the maximum allowed length of the SQL varchar datatype depends on the underlying DBMS. Most DBMSes allow for at least 2000 characters. Some old versions of MySql did have a limit of 255 characters (see http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html, section "VARCHAR"). Therefore, I would propose to set the limit to 255 instead of 254, or, if it makes sense, to make it configurable in the ODBC plugin.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            andysh Andy Shaw
            sven steinseifer Sven Steinseifer
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes