Error when loading any dataset from TIBCQuery through TDataSetProvider

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
l_vaskov
Posts: 6
Joined: Fri 02 Oct 2009 13:58

Error when loading any dataset from TIBCQuery through TDataSetProvider

Post by l_vaskov » Wed 15 Nov 2017 16:10

Hello IBDAC team,

I encountered an error when I upgraded to the latest IBDAC version - 6.1.4.

I try to load a TClientDataSet from TIBCQuery through TDataSetProvider. The query selects just 3 fields - a bigint, a date and a double precision field:

Code: Select all

cdsTest.Close;
ibqTest.Close;
ibqTest.Open;
cdsTest.Data := prvTest.Data;
When I do this, an error is raised - '0.0' is not a valid timestamp. I found that this problem appears when the persistent fields in the query and the client dataset are ordered differently. Loading of the data does not find the correct fields to load data from and this causes the error.

I think I found which method causes the issue in module MemDS.pas. I replaced the code with the old version from IBDAC 5.7 and the problem disappeared:

Code: Select all

{$IFNDEF FPC}
function TMemDataSet.GetFieldData(FieldNo: integer; Buffer: IntPtr): boolean;
var
  RecBuf: TRecordBuffer;
  Field: TField;
  {BEGIN FIX version 5.7.}
  IsBlank: boolean;
  FieldDesc: TFieldDesc;
  {END FIX}
begin
//if BlockReadSize > 0 then

  Result := GetActiveRecBuf(RecBuf);
  if Result then begin
    Assert(Data <> nil);

    {BEGIN FIX}
    //ORIGINAL CODE - version 6.1.4. - this causes the problem
    {if FieldNo > 0 then
      Field := Fields[FieldNo - 1]
    else
      Field := FieldByNumber(FieldNo);

    if Field <> nil then begin
      Result := GetFieldData(Field, Buffer);
      if Result and (Field.DataType in [ftBCD, ftSmallint, ftWord]) then
        Result := InternalDataConvert(Field, Buffer, Buffer, True);}
		
    //FIXED CODE - version 5.7. - this works fine		
    FieldDesc := GetFieldDesc(FieldNo);
    Data.GetField(FieldDesc, RecBuf, Buffer, True, IsBlank);
    Result := not IsBlank;

    if Result then begin
      Field := FieldByNumber(FieldNo);
      if Field.DataType in [ftBCD, ftSmallint, ftWord] then
        Result := InternalDataConvert(Field, Buffer, Buffer, True);
  {END FIX}		
    end
    else
      Result := False;
  end;
end;
{$ENDIF}
I will send you a zip file to viktorv*devart*com, containing a project to simulate the issue and a simple script to create a test database.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Error when loading any dataset from TIBCQuery through TDataSetProvider

Post by ViktorV » Wed 15 Nov 2017 16:42

Thank you for the interest in our products.
We have already fixed the issue. This fix will be included in the next build of IBDAC. To make a correct fix, you should change the code in the method you described:

Code: Select all

    if FieldNo > 0 then
      Field := Fields[FieldNo - 1]
    else
      Field := FieldByNumber(FieldNo);
to

Code: Select all

    Field := FieldByNumber(FieldNo);

Post Reply