Subject Re: [firebird-support] Instead-Of-Tigger on view causes infinite loop (probably in the engine!)
Author Andrea Sansottera
Good refactoring Ann (thanks!)

Anyway the problem is still present.

UPDATE "IngredientView" set "Insat" = 1000
seems to cause an infinte loop.

UPDATE "IngredientView" set "Insat" = 1000 where "Code" = 'ing01'
works well.

The problem is in the trigger:

>CREATE TRIGGER "IngredientViewEditingIU1" FOR "IngredientView" ACTIVE
>BEFORE INSERT OR UPDATE POSITION 1
>AS
> declare variable "versionID" BIGINT;
> declare variable "versionNumber" BIGINT;
>BEGIN
>
> /* Generate ID */
> EXECUTE PROCEDURE GENERATE_VERSIONS (new."Code", new."Description")
> RETURNING_VALUES (:"versionID", :"VersionNumber");
>
> insert into "Ingredient"
> ("ID", "TypeID", "Acq", "Peq", "Insat", "Me", "Face",
> "Fohe", "Cost")
> values (:"versionID", new."TypeID", new."Acq", new."Peq",
> new."Insat", new."Me", new."Face", new."Fohe",
> new."Cost");
>
>END^
>
>
As I said before removing the INSERT INTO "Ingredient" statement solves
the problem.

<GUESS>
There could be any reason which causes the engine to confuse
"Ingredient" with "IngredientView", only when updating 2 or more rows?
Inserting into "IngredientView" obviously would couse an infinite
recursion in the trigger chain.
</GUESS>

Regards, Andrea

--
Andrea Sansottera
UGIdotNET [Italian] http://www.ugidotnet.org
My weblog [Italian] http://blogs.ugidotnet.org/andrew/