VirtualTable and LargeInt field

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

VirtualTable and LargeInt field

Post by FCS » Thu 31 Mar 2016 09:29

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: VirtualTable and LargeInt field

Post by AlexP » Thu 31 Mar 2016 10:12

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.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: VirtualTable and LargeInt field

Post by FCS » Thu 31 Mar 2016 12:55

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: VirtualTable and LargeInt field

Post by AlexP » Thu 31 Mar 2016 13:25

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.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: VirtualTable and LargeInt field

Post by FCS » Thu 31 Mar 2016 15:14

Hello,

There are any solution ?

Regards
Michal

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: VirtualTable and LargeInt field

Post by AlexP » Fri 01 Apr 2016 04:54

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.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: VirtualTable and LargeInt field

Post by FCS » Fri 01 Apr 2016 05:35

Hello,

Thanks Alex. It works.

Regards
Michal

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: VirtualTable and LargeInt field

Post by AlexP » Fri 01 Apr 2016 06:16

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply