TDAMemDataTable: -1 Can't refresh delta, record isn't found

Hi

Using Delphi 10.3 & RODA Version 10.0.0.1579
A simple Insert statement with an ID field (primary key) using a sequence in SQL Server 2019.
Although the record is correctly inserted, an error occurs.

Error: -1: Can’t refresh delta, record isn’t found

procedure TfrmMain.Button1Click(Sender: TObject);
var
  mData: TdmDetailData;
begin
  mData := TdmDetailData.Create(Self);
  try
    mData.tblQuestions.Open;
    with mData.tblQuestions do
    begin
      Insert;
      FieldByName('Question').AsString := 'Does it work now?';
      FieldByName('Subject').AsInteger := 2;
      FieldByName('Category').AsInteger := 1;
      FieldByName('MaxTime').AsInteger := 10;
      FieldByName('MotivationTime').AsInteger := 0;
      Post;
      ApplyUpdates;
    end;
  finally
    mData.Free;
  end;
end;

image

Hi,

can you create a simple testcase that reproduces this case, pls?

You can drop it to support@ for keeping privacy.


I’ve used this testcase for testing sequences
testcase.zip (96.9 KB)

DDL:

CREATE TABLE [dbo].[Table_seq](
	[id] [bigint] NOT NULL,
	[name] [nvarchar](50) NULL,
 CONSTRAINT [PK_Table_seq] PRIMARY KEY CLUSTERED 
(
	[id] ASC
) ON [PRIMARY]
GO

CREATE SEQUENCE [dbo].[seq1] 
 AS [bigint]
 START WITH 1
 INCREMENT BY 1
GO

I executed your testcase on my SQL 2019 DB with FireDAC connection based on your DDL.

image

I added this to the DDL

ALTER TABLE Table_seq ADD CONSTRAINT DF_Table_seq_id DEFAULT (NEXT VALUE FOR [seq1]) FOR id

Executing the addrecord and applyupdates results in the same error.

Could this be FireDAC related? Or maybe the ODBC Driver 17?
The record is inserted, but the error occurs.

So, if you adjust the testcase with another connection (FireDAC), the error should occur.

Regards,
Filip

Hi,

update uDAFireDACDriver.pas as

function TDAEFireDACConnection.QueryInterface(const IID: TGUID; out Obj): HResult;
..
  end else if IsEqualGUID(IID, IDAUseGenerators) or IsEqualGUID(IID, IDAUseGenerators2) then begin
    if not (fDriverType in [mkInterBase, mkFirebird, mkOracle, mkPostgreSQL, mkMSSQL]) then Exit; // changed

it should solve this issue

Logged as bugs://D19411.

bugs://D19411 was closed as fixed.