Subject | RE: [firebird-support] Re: multiple inserts in trigger |
---|---|
Author | Ross Ryding |
Post date | 2007-07-11T15:11:29Z |
Does anyone know how expensive it is to fire off 50 triggers on an update
that do a single insert to a table as oppose to inline code that tests for
50 cases and one trigger fired? Is firing a trigger in firebird lightweight
of heavy?
_____
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ross Ryding
Sent: Wednesday, July 11, 2007 9:52 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Re: multiple inserts in trigger
Ok, I broke each test off into a separate trigger and it works fine. This
does not make sense to me since it should be the same difference. In single
file many tests I am doing a After Update so the second fire of the UPDATE
trigger for the second field change should test the first value as no change
and thus skip it. I tried doing one as an insert command and the other as a
select command reducing the procedure just down to two tests and it still
hangs. When I do one at a time it inserts the record when I do two changes
with two tests in one trigger neither update the audit file.
Does this make sense to anyone?
I really thought I was smarter than this
-----Original Message-----
From: firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com
[mailto:firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com] On Behalf Of Sasha
Sent: Wednesday, July 11, 2007 7:59 AM
To: firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com
Subject: RE: [firebird-support] Re: multiple inserts in trigger
true if either a or b is null and that's by design.
If you want to test for nulls you must rewrite it like this:
if ((a is null and b is null) or a=b) then -- your test condition might be
different
begin
-- something
end else
begin
-- something else
end
or simpler like this:
if (a is not distinct from b) then
something;
else
something else
I think is [not] distinct was introduced in FB 2.0.0 so if you are running
earlier version you will not be able to use it, but you should check on
that.
Sasha
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebird <http://www.firebirdsql.org> sql.org and click the
Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoeni
<http://www.ibphoenix.com> x.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
[Non-text portions of this message have been removed]
that do a single insert to a table as oppose to inline code that tests for
50 cases and one trigger fired? Is firing a trigger in firebird lightweight
of heavy?
_____
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ross Ryding
Sent: Wednesday, July 11, 2007 9:52 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Re: multiple inserts in trigger
Ok, I broke each test off into a separate trigger and it works fine. This
does not make sense to me since it should be the same difference. In single
file many tests I am doing a After Update so the second fire of the UPDATE
trigger for the second field change should test the first value as no change
and thus skip it. I tried doing one as an insert command and the other as a
select command reducing the procedure just down to two tests and it still
hangs. When I do one at a time it inserts the record when I do two changes
with two tests in one trigger neither update the audit file.
Does this make sense to anyone?
I really thought I was smarter than this
-----Original Message-----
From: firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com
[mailto:firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com] On Behalf Of Sasha
Sent: Wednesday, July 11, 2007 7:59 AM
To: firebird-support@ <mailto:firebird-support%40yahoogroups.com>
yahoogroups.com
Subject: RE: [firebird-support] Re: multiple inserts in trigger
> I would have never thought of that, great idea and greatlyIn a nutshell yes, but you must understand that if(a = b) will never return
> appreciated. I
> assume that distinct understands the NULL state.
>
true if either a or b is null and that's by design.
If you want to test for nulls you must rewrite it like this:
if ((a is null and b is null) or a=b) then -- your test condition might be
different
begin
-- something
end else
begin
-- something else
end
or simpler like this:
if (a is not distinct from b) then
something;
else
something else
I think is [not] distinct was introduced in FB 2.0.0 so if you are running
earlier version you will not be able to use it, but you should check on
that.
Sasha
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebird <http://www.firebirdsql.org> sql.org and click the
Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoeni
<http://www.ibphoenix.com> x.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
[Non-text portions of this message have been removed]