Page 1 of 1

VirtualTable and LargeInt field

Posted: Thu 31 Mar 2016 09:29
by FCS
Hello,

I have problem with LargeInt field in VT.
The Int64 values stored in that field are converted to integers and are overloaded (positives goes to negatives).
The export to XML file is incorrect too.
Meanwhile I use the float fields to store Int64 values.
Is there a bug or I do something wrong ?

Regards
Michal

Re: VirtualTable and LargeInt field

Posted: Thu 31 Mar 2016 10:12
by AlexP
Hello,

The below code demonstrates correct functioning of VirtualTable. Please modify so that the issue is reproduced, and send it back to us.

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, Data.DB, VirtualTable;

var
  VT: TVirtualTable;
begin
  VT := TVirtualTable.Create(nil);
  try
    VT.AddField('Largeint', ftLargeint);
    VT.Open;
    VT.Append;
    VT.FieldByName('Largeint').AsLargeInt := High(Int64);
    VT.Post;
    VT.Refresh;
    Writeln(IntToStr(VT.FieldByName('Largeint').AsLargeInt));
  finally
    VT.Free;
    readln;
  end;
end.

Re: VirtualTable and LargeInt field

Posted: Thu 31 Mar 2016 12:55
by FCS
Hello Alex,

This project doesn't compile.

VT.FieldByName('Largeint').AsLargeInt := High(Int64);

The AsLargeInt doesn't exist. I use UniDac 6.1.6 and BDS 2006 Prof.

Regards
Michal

Re: VirtualTable and LargeInt field

Posted: Thu 31 Mar 2016 13:25
by AlexP
This behavior is due to implementation of the standard method SetAsInteger в классе TLargeintField in the DB.pas module. The parameter of this method is an argument with Longint type, therefore a value greater than Longint will be mapped as -1.

Re: VirtualTable and LargeInt field

Posted: Thu 31 Mar 2016 15:14
by FCS
Hello,

There are any solution ?

Regards
Michal

Re: VirtualTable and LargeInt field

Posted: Fri 01 Apr 2016 04:54
by AlexP
for RAD Studio 2006

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  SysUtils, DB, VirtualTable;

var
  VT: TVirtualTable;
begin
  VT := TVirtualTable.Create(nil);
  try
    VT.AddField('Largeint', ftLargeint);
    VT.Open;
    VT.Append;
    TLargeintField(VT.FieldByName('Largeint')).AsLargeInt := High(Int64);
    VT.Post;
    VT.Refresh;
    Writeln(IntToStr(TLargeintField(VT.FieldByName('Largeint')).AsLargeInt));
  finally
    VT.Free;
    readln;
  end;
end.

Re: VirtualTable and LargeInt field

Posted: Fri 01 Apr 2016 05:35
by FCS
Hello,

Thanks Alex. It works.

Regards
Michal

Re: VirtualTable and LargeInt field

Posted: Fri 01 Apr 2016 06:16
by AlexP
Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.