Subject | Re: [IBO] Exception "multiple records inserted" |
---|---|
Author | Helen Borrie |
Post date | 2005-01-04T23:27:35Z |
At 06:57 PM 4/01/2005 +0000, you wrote:
returned from the execution of the DML statement. It uses this number to
determine whether the Insert statement it passed across the wire had the
logically proper effect of inserting one and only one row to the dataset's
underlying table.
there and return the rows affected count to the client, it would be 1,
which IBO's reality check would accept. With your trigger, in turn, the
server proceeds to insert some rows into another table. As it does each of
these "secondary" inserts, it increments the count of rows affected. Thus,
when IBO finally gets the count, it is more than one, and IBO delivers a
warning about it - the message you saw.
particular Insert call is going to cause this condition when the Insert
operation executes the DML --- and you know that it's OK. To you, this
particular exception is merely an alert that confirms that your Insert
operation had the desired effect. So just handle that particular exception
and swallow it. (If you don't, of course IBO has no way get past the
exception condition other than to raise it and stop the show!!)
exist. :-)
Helen
>Hi,On the client side, IBO has no knowledge of triggers or their effects.
>
>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, butCorrect. IBO reads the RowsAffected count from the structure that is
>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.
returned from the execution of the DML statement. It uses this number to
determine whether the Insert statement it passed across the wire had the
logically proper effect of inserting one and only one row to the dataset's
underlying table.
> I suspect that IBO checks how many rows were affected after theFor the server's part, it performs the single insert. If it were to stop
> insert, and it only allows for a single row - anything else and IBO
> throws an exception.
there and return the rows affected count to the client, it would be 1,
which IBO's reality check would accept. With your trigger, in turn, the
server proceeds to insert some rows into another table. As it does each of
these "secondary" inserts, it increments the count of rows affected. Thus,
when IBO finally gets the count, it is more than one, and IBO delivers a
warning about it - the message you saw.
>Is there any way to tell IBO to allow more than 1 row per insert?No, but no workaround is necessary! As the programmer, you know that this
>Maybe another workaround?
particular Insert call is going to cause this condition when the Insert
operation executes the DML --- and you know that it's OK. To you, this
particular exception is merely an alert that confirms that your Insert
operation had the desired effect. So just handle that particular exception
and swallow it. (If you don't, of course IBO has no way get past the
exception condition other than to raise it and stop the show!!)
>Note that using a stored procedure isn't a good solution, because itQuite right. That would be a "workaround" for a problem that doesn't
>means I have to write and maintain dozens of SPs, which is a nightmare.
exist. :-)
Helen