smarthaert / txquery

Automatically exported from code.google.com/p/txquery
Other
0 stars 0 forks source link

LargeInt data type not supported in parameters #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a table with dtLargeInt field behind and if I use update sql it throws 
error. I added ftLargeInt in this procedure and now it works.

Function TSqlAnalizer.ReplaceParams(const SQL: string): String;
var
  List: TParams;
  I, DblQuote, Quote: Integer;
  ParamValue: string;
  Param: TParam;
begin
  List := TParams.Create(Nil);
  try
    Result:= List.ParseSQL(SQL, True); // Result:= StrPas(PChar(List.ParseSQL(SQL, True))); {patched by ccy}
    for I:= 0 to List.Count - 1 do
    begin
      Param:= xQuery.ParamByName(List[I].Name);
      if Param <> Nil then
      begin
        case Param.DataType of
          ftBlob:
            ParamValue := #34 + StringToHex(Param.AsString) + #34;
          ftString, ftWideString: { patched by ccy }
            begin
              ParamValue:= Param.Asstring;
              DblQuote:= AnsiPos(#34, ParamValue);
              Quote:= AnsiPos(#39, ParamValue);
              if (Quote > 0) and (DblQuote = 0) then
                ParamValue:= #34 + ParamValue + #34
              else if (DblQuote >= 0) and (Quote = 0) then
                ParamValue:= #39 + ParamValue + #39
              else
                ParamValue:= #39 + ParamValue + #39;
            end;
          ftFloat, ftCurrency, ftBCD, ftAutoInc, ftSmallInt, ftInteger, ftWord, ftFmtBcd, ftLargeInt : { patched by ccy }
            ParamValue:= Param.Asstring;
          ftDate, ftTime, ftDateTime:
            ParamValue:= FloatToStr(Param.AsFloat);
          ftBoolean:
            ParamValue:= xqbase.NBoolean[Param.AsBoolean];
        end;
        Result:= StringReplace(Result, '?', ParamValue, [rfIgnoreCase]);
      end;
    end;
  finally
    List.free;
  end;
end;

Original issue reported on code.google.com by grega.lo...@gmail.com on 27 Dec 2012 at 9:23