Subject Re: Instead-Of-Tigger on view causes infinite loop (probably in the engine!)
Author Andrea Sansottera
Andrea Sansottera wrote:

> Hi all,
> I'm facing a quite serious problem. Please tell me whether I'm doing
> something wrong or I've found a bug.
>
> I have a View, "IngredientView", which selects data from "Element",
> "ElementVersion" and "Ingredient".
> I've made it update through a trigger, "IngredientViewEditing" which
> fires on insert/update/delete.
>
> Insertion and deletion works well, even if I'm deleting more than one
> row. Update statements works as well, but only if I'm updating a
> single row. If i try to update two or more row, the engine seems to
> enter in an infinite loop.
>
> Both 1.5.1 and 1.5.2 versions of Firebird don't work.
>
> The trigger code is attached. Please tell me if I'm doing something
> wrong.

I've also noticed that removing the line
insert into "Ingredient" ...
solves the problem (but the trigger does not do anything useful anymore!).

If it may be useful, the view is defined in this way:

CREATE VIEW "IngredientView" (
"Code",
"CurrentVersion",
"LastUpdateAuthor",
"LastUpdateTimestamp",
"StateID",
"TypeID",
"Peq",
"Insat",
"Acq",
"Me",
"Face",
"Fohe",
"Cost",
"Description")
AS
SELECT
E."Code",
E."CurrentVersion",
E."LastUpdateAuthor",
E."LastUpdateTimestamp",
E."StateID",
I."TypeID",
I."Peq",
I."Insat",
I."Acq",
I."Me",
I."Face",
I."Fohe",
I."Cost",
EV."Description"
FROM "Element" E
INNER JOIN "ElementVersion" EV
ON E."Code" = EV."Code" AND E."CurrentVersion" = EV."Version"
INNER JOIN "Ingredient" I
ON EV."ID" = I."ID"
WHERE
(E."StateID" = 1 or E."StateID" = -1)
AND
(SELECT "View" FROM "GetPrivileges" (E."Code", current_user)) <> 0;

Thanks in advance...

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