Sample code for use of triggers in hsqldb.
SQL to invoke is:
CREATE TRIGGER triggerSample BEFORE|AFTER INSERT|UPDATE|DELETE
ON myTable [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL "myPackage.trigClass"
This will create a thread that will wait for its firing event to occur;
when this happens, the trigger's thread runs the 'trigClass.fire'
Note that this is still in the same Java Virtual Machine as the
database, so make sure the fired method does not hang.
There is a queue of events waiting to be run by each trigger thread.
This is particularly useful for 'FOR EACH ROW' triggers, when a large
number of trigger events occur in rapid succession, without the trigger
thread getting a chance to run. |