+1 to this.
Knowing at initialization time that the trigger has been defined for DELETE, UPDATE and INSERT
has no use at least I have not found any.

If you use the same class for different types of events then chances are that there is only some slight variations in the behaviour based on the event type and these will be handled in the fire method.

But currently the fire method does not know what event triggered it.

So instead of telling the init method all possible events we should tell the fire method
the actual event that triggered it.

Workaround:

Instead of
CREATE TRIGGER foo_history_trigger AFTER INSERT, UPDATE, DELETE ON foo FOR EACH ROW CALL "MyTrigger";

Use
CREATE TRIGGER foo_history_trigger_i AFTER INSERT ON foo FOR EACH ROW CALL "MyTrigger"; CREATE TRIGGER foo_history_trigger_u AFTER UPDATE ON foo FOR EACH ROW CALL "MyTrigger"; CREATE TRIGGER foo_history_trigger_d AFTER DELETE ON foo FOR EACH ROW CALL "MyTrigger";

Fix:
fire <http://www.h2database.com/javadoc/org/h2/api/Trigger.html#fire_Connection_Object-_Object->(Connection conn, Object[] oldRow, Object[] newRow, int type) throws SQLException

And here the type would be only one of INSERT, UPDATE and DELETE.

- rami

On 29.6.2011 1:54, cowwoc wrote:
2. Add a new "type" parameter to the fire() method so we can act on
the actual type that gets fired (better from a performance point of
view). I would keep the "type" parameter in init() in case someone
needs to initialize differently depending on the range of operations a
trigger may handle.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to