Subject RE: [firebird-support] Too many concurrent executions of the same request
Author Svein Erling Tysvær
>Hello,
>
>I have table Invoice (which is header table) and InvoiceItem (which is items table) and InvoiceID as foreign key in secound >table which is reference first table.
>Now, I have some fields which is sum or products of some another columns in InvoiceItems which is depend of business logic.
>So, I was create a trigger and procedure for InvoisItem table:
>
>CREATE OR ALTER TRIGGER INVOICEITEMS_A0 FOR INVOICEITEMS
>ACTIVE AFTER INSERT OR UPDATE POSITION 0
>AS
>BEGIN
> EXECUTE PROCEDURE SP_ADM_SUMFIELDS('INVOICEITEMS', NEW.INVOICEID);
>END
>
>CREATE OR ALTER PROCEDURE SP_ADM_SUMFIELDS (TABLENAME VARCHAR(30), ID INTEGER)
>AS
>BEGIN
> UPDATE INVOICEITEMS SET SUMCOLUMN = COLUMN1 + COLUMN2 WHERE INVOICEID = :ID;
> SUSPEND;
>END
>
>Where is a Firebird Leak error???

Typically, you would update the same table in BEFORE INSERT trigger, not AFTER INSERT. Moreover, you treat your stored procedure as an executable procedure and I think SUSPEND belongs to selectable procedures.

Having said that, I've never tried calling a stored procedure from within a trigger (be it BEFORE or AFTER) to update my own table (I think I would try to look for a way to avoid that, logically I would not be surprised if your stored procedure call resulted in a recursive execution of the trigger), and I do not know whether the two things I've mentioned is related to your problem or not.

HTH,
Set