EDatabaseError 'Update failed. Found 2 records'.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jmuehlenhoff
Posts: 36
Joined: Fri 30 Apr 2010 11:25

EDatabaseError 'Update failed. Found 2 records'.

Post by jmuehlenhoff » Fri 27 Jun 2014 09:45

Hi,

I get the following error:

Code: Select all

EDatabaseError 'Update failed. Found 2 records'.
It is caused by an AFTER INSERT TRIGGER on the table that is being inserted to.

Code: Select all

CREATE TRIGGER
  [dbo].[AdresseAfterInsert]
ON
  [dbo].[Adresse]
AFTER INSERT
AS
INSERT INTO
  [dbo].[AdresseDatenkreis]
(
    [Adresse_ID]
  , [Datenkreis_ID]
  , [Zugeordnet]
)
SELECT
    ins.[Adresse_ID]
  , dat.[Datenkreis_ID]
  , dat.[Default]
FROM
  [inserted] ins
CROSS JOIN
  [dbo].[Datenkreis] dat
WHERE
  dat.[Ruecklaeufer] = 0
As you can see the trigger does an additional INSERT into another table, but that causes the TMSQuery to fail.

Any ideas?

Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

Re: EDatabaseError 'Update failed. Found 2 records'.

Post by Ludek » Fri 27 Jun 2014 10:38

i had the same problem 7 years ago:
http://forums.devart.com/viewtopic.php?f=6&t=9606

jmuehlenhoff
Posts: 36
Joined: Fri 30 Apr 2010 11:25

Re: EDatabaseError 'Update failed. Found 2 records'.

Post by jmuehlenhoff » Fri 27 Jun 2014 10:45

Thanks Ludek, that sheds some light on what is going on.

If I understood correctly we have these options:

1. Use SET NOCOUNT ON in the trigger
2. Set StrictUpdate to False
3. Set MSAccess.__UseUpdateOptimization to False

Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

Re: EDatabaseError 'Update failed. Found 2 records'.

Post by Ludek » Fri 27 Jun 2014 11:36

I think you understand it perfectly :)

Post Reply