Subject | Exception "multiple records inserted" |
---|---|
Author | Eyal |
Post date | 2005-01-04T18:57:37Z |
Hi,
On a Firebird DB, I set up a table with a "before insert" trigger.
When a new records is added to the table, the trigger automatically
adds a record in another table.
This is a very common scenario for activity logging, although I use it
for some other purposes as well.
I tested this setup with direct SQL commands, and it works as it
should. However when I try to insert through a Delphi form with IBO
query, I get an exception that reads "multiple records inserted".
I tried everything I could think of, and I searched everywhere, but
could not find a mention of such a problem. Then I searched through
IB_Constants.DCU and found the exception string in there. This hints
that IBO throws the exception, not Firebird.
I suspect that IBO checks how many rows were affected after the
insert, and it only allows for a single row - anything else and IBO
throws an exception.
Is there any way to tell IBO to allow more than 1 row per insert?
Maybe another workaround?
Note that using a stored procedure isn't a good solution, because it
means I have to write and maintain dozens of SPs, which is a nightmare.
Thanks,
Eyal.
On a Firebird DB, I set up a table with a "before insert" trigger.
When a new records is added to the table, the trigger automatically
adds a record in another table.
This is a very common scenario for activity logging, although I use it
for some other purposes as well.
I tested this setup with direct SQL commands, and it works as it
should. However when I try to insert through a Delphi form with IBO
query, I get an exception that reads "multiple records inserted".
I tried everything I could think of, and I searched everywhere, but
could not find a mention of such a problem. Then I searched through
IB_Constants.DCU and found the exception string in there. This hints
that IBO throws the exception, not Firebird.
I suspect that IBO checks how many rows were affected after the
insert, and it only allows for a single row - anything else and IBO
throws an exception.
Is there any way to tell IBO to allow more than 1 row per insert?
Maybe another workaround?
Note that using a stored procedure isn't a good solution, because it
means I have to write and maintain dozens of SPs, which is a nightmare.
Thanks,
Eyal.