Subject | Re: Query a table within its trigger |
---|---|
Author | hanszorn2000 |
Post date | 2012-07-05T17:11:49Z |
--- In firebird-support@yahoogroups.com, "unordained" <unordained_00@...> wrote:
Hans
> >Like I wrote the example is simplified. Handling of that situation was omitted.
> > declare LOCATION integer;
> > declare ARTICLEID varchar(20);
> > BEGIN
> > select first 1 NEWLOCATION, ARTICLEID from ARTICLE
> > where ARTICLE.CUSTID = NEW.CUSTID
> > and ARTICLE.ISACTIVE = 'F'
> > and ARTICLE.NEWLOCATION is not null
> > order by NEWLOCATION
> > into :LOCATION, :ARTICLEID;
> >
> > NEW.NEWLOCATION = LOCATION;
> > end
> >
> > This then (sometimes) assigns values of NEWLOCATION for Articles with
> > ISACTIVE = 'T'.
> ------- End of Original Message -------
>
> Here's my reversed-engineered documentation for the order of operations of
> Firebird triggers (in the context of other stuff going on):
>
> http://pseudotheos.com/view_object.php?object_id=1619
>
> In your case, I'd be worried about:
> - default value of :LOCATION when "first 1" finds none
> - concurrent transactions (you're sure the trigger would have known thoseThe problrm also occurs with only one user (in our test environment).
> articles were active?)
> - are you ever bulk-inserting articles that are all for the same customer? (aWe sometimes do. But as it also happens with single inserts, I'll worry about those later.
> bulk-insert operation may do its job in any order, but the trigger for each row
> as it happens, weird things could happen)
Hans