Subject | Re: Problem with trigger - too many concurrent executions |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-12-07T15:10:06Z |
Hi Peter!
AFTER INSERT should be used for updating other tables, you want to do
something like:
CREATE TRIGGER "INPT_lmd" FOR INPT ACTIVE
BEFORE INSERT OR UPDATE POSITION 1
AS
BEGIN
NEW.LMD='now';
END
HTH,
Set
AFTER INSERT should be used for updating other tables, you want to do
something like:
CREATE TRIGGER "INPT_lmd" FOR INPT ACTIVE
BEFORE INSERT OR UPDATE POSITION 1
AS
BEGIN
NEW.LMD='now';
END
HTH,
Set
--- In firebird-support@yahoogroups.com, "peter_nn0" wrote:
> Hi,
>
> I have a table with a field named LMD (Timestamp) where I want to
> store the last modified date/time for each record in the same table.
>
> For this purpose I created a trigger like this
> ----------------
> CREATE TRIGGER "INPT_lmd" FOR INPT ACTIVE
> AFTER INSERT OR UPDATE POSITION 1
> AS
> BEGIN
> update INPT set INPT.LMD='now';
> END
> -----------------
> The idea is - if a record is added or modified, the LMD field to be
> set to the time of addition/modification.
>
> The problem is that when I try to add a new record, I get an
> error "too many concurrent executions of the same request"
> If I remove the trigger, new records can be added OK.
> I'm surely the only one connected to the DB.
>
> Could it be that the trigger triggers itself and goes in a loop?
> Like after INSERT it updates the LMD field, and this update triggers
> it again (as we have after UPDATE too) and so on and so on?
> If yes, what's the proper way to write such a trigger?
>
> Thanks
> ------------
> FB server 1.5.2.4731 running on the same machine - XP sp2