Subject RE: [firebird-support] Is it a Trigger Problem?
Author Omacht András
Hi Zoran!

I suggest you to make unique key on
"T_ORDERCUSTOMER".OrderId
and
T_ORDERVEHICLE".OrderId

and you will get an exception when the secound row is inserted into the tables.

Maybe this helps to find out where is the problem.

Andr�s

From: firebird-support@yahoogroups.com <firebird-support@yahoogroups.com>
Sent: Wednesday, July 17, 2019 4:47 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Is it a Trigger Problem?


This might sound impossible...

I have one master and two detail tables. Relation is defined thru Foreign Key and cascade delete. When I insert a master row, the master table trigger inserts one empty detail row (only master key column populated)) in each of the two detail tables. So each master row has only one detail row in each of two detail tables and that doesn't change during the life of a master row.

All works well. Very, very seldom my client gets two detail rows for the same master row. Sometimes it is in detail 1 table, sometimes it is in detail 2 table. There are 5 users updating and inserting new rows 8 hours a day. Database size is small (about 10,000 rows in the main table).

Application code does not insert any rows into detail tables, just updates them. There are several triggers in the database, but the only one that touches detail tables is the one in the master table.

Now crazy question. How is this possible? Is there any special circumstance in FB which might cause this?

Here is part of the trigger in master table:

if (INSERTING) then
begin
insert into "T_ORDERCUSTOMER" (OrderId) values (new.Id);
insert into "T_ORDERVEHICLE" (OrderId) values (new.Id);
...

Server: FB 3.4, Win 10 Pro, 12GB RAM

Workstations: Win 10 Home and Pro, 4-8GB RAM
Development: Delphi 10.3.1, Win 10 Ent, 32GB RAM

Tnx.



__________ Information from ESET Mail Security, version of virus signature database 19701 (20190717) __________

The message was checked by ESET Mail Security.
http://www.eset.com



__________ Information from ESET Mail Security, version of virus signature database 19705 (20190718) __________

The message was checked by ESET Mail Security.
http://www.eset.com



[Non-text portions of this message have been removed]