Page 1 of 1

EDatabaseError 'Update failed. Found 2 records'.

Posted: Fri 27 Jun 2014 09:45
by jmuehlenhoff
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?

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

Posted: Fri 27 Jun 2014 10:38
by Ludek
i had the same problem 7 years ago:
http://forums.devart.com/viewtopic.php?f=6&t=9606

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

Posted: Fri 27 Jun 2014 10:45
by jmuehlenhoff
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

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

Posted: Fri 27 Jun 2014 11:36
by Ludek
I think you understand it perfectly :)