Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Multi-action triggers<br />
Added in: 1.5<br />
DDL statements<br />
Description: Relation triggers can be defined to fire upon multiple operations (INSERT and/or UPDATE and/or<br />
DELETE). Three new boolean context variables (INSERTING, UPDATING and DELETING) have been added so<br />
you can execute code conditionally within the trigger body depending on the type of operation.<br />
Example:<br />
create trigger biu_parts for parts<br />
before insert or update<br />
as<br />
begin<br />
/* conditional code when inserting: */<br />
if (inserting and new.id is null)<br />
then new.id = gen_id(gen_partrec_id, 1);<br />
/* common code: */<br />
new.partname_upper = upper(new.partname);<br />
end<br />
Note<br />
In multi-action triggers, both context variables OLD and NEW are always available. If you use them in the<br />
wrong situation (i.e. OLD while inserting or NEW while deleting), the following happens:<br />
• If you try to read their field values, NULL is returned.<br />
• If you try to assign values to them, a runtime exception is thrown.<br />
BEGIN ... END blocks may be empty<br />
Changed in: 1.5<br />
Description: BEGIN ... END blocks may be empty in <strong>Firebird</strong> 1.5 and up, allowing you to write stub code without<br />
having to resort to dummy statements.<br />
Example:<br />
create trigger bi_atable for atable<br />
active before insert position 0<br />
as<br />
begin<br />
end<br />
CREATE TRIGGER no longer increments table change count<br />
Changed in: 1.0<br />
Description: In contrast to InterBase, <strong>Firebird</strong> does not increment the metadata change counter of the associated<br />
table when CREATE, ALTER or DROP TRIGGER is used. For a full discussion, see ALTER TRIGGER no longer<br />
increments table change count.<br />
49