Browse Source

odbc: bind string parameters as SQL_WLONGVARCHAR only for more than 2000 characters

Ondrej Pokorny 3 years ago
parent
commit
f57adee862
1 changed files with 5 additions and 4 deletions
  1. 5 4
      packages/fcl-db/src/sqldb/odbc/odbcconn.pas

+ 5 - 4
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -505,10 +505,11 @@ begin
           ColumnSize:=Size; //The defined or maximum column size in characters of the column or parameter
           ColumnSize:=Size; //The defined or maximum column size in characters of the column or parameter
           BufferLength:=Size;
           BufferLength:=Size;
           CType:=SQL_C_WCHAR;
           CType:=SQL_C_WCHAR;
-          case AParams[ParamIndex].DataType of
-            ftFixedChar, ftFixedWideChar: SqlType:=SQL_WVARCHAR;
-            else SqlType:=SQL_WLONGVARCHAR;
-          end;
+          if (AParams[ParamIndex].DataType in [ftMemo, ftWideMemo])
+          or (Length(WideStrVal)>2000) then // long texts (more than 2000 unicode characters) must be bound as SQL_WLONGVARCHAR
+            SqlType:=SQL_WLONGVARCHAR
+          else
+            SqlType:=SQL_WVARCHAR;
         end;
         end;
       ftSingle:
       ftSingle:
         begin
         begin