-
public interface Trigger
The interface a HyperSQL TRIGGER must implement. The user-supplied class that implements this must have a default constructor.Contents of oldRow[] and newRow[] in each type of trigger.
- AFTER INSERT oldRow[] contains single String object = "Statement-level".
- AFTER UPDATE oldRow[] contains single String object = "Statement-level".
- AFTER DELETE oldRow[] contains single String object = "Statement-level".
- BEFORE INSERT FOR EACH ROW newRow[] contains data about to be inserted and this can be modified within the trigger such that modified data gets written to the database.
- AFTER INSERT FOR EACH ROW newRow[] contains data just inserted into the table.
- BEFORE UPDATE FOR EACH ROW oldRow1[] contains currently stored data and not the data that is about to be updated.
- newRow[] contains the data that is about to be updated.
- AFTER UPDATE FOR EACH ROW oldRow1[] contains old stored data. newRow[] contains the new data.
- BEFORE DELETE FOR EACH ROW oldRow1[] contains row data about to be deleted.
- AFTER DELETE FOR EACH ROW oldRow1[] contains row data that has been deleted.
- Since:
- 1.7.0
- Author:
- Peter Hudson (peterhudson@users dot sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static int
DELETE_AFTER
static int
DELETE_AFTER_ROW
static int
DELETE_BEFORE_ROW
static int
INSERT_AFTER
static int
INSERT_AFTER_ROW
static int
INSERT_BEFORE_ROW
static int
UPDATE_AFTER
static int
UPDATE_AFTER_ROW
static int
UPDATE_BEFORE_ROW
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
fire(int type, java.lang.String triggerName, java.lang.String tableName, java.lang.Object[] oldRow, java.lang.Object[] newRow)
Old fire method.default void
fire(int type, java.lang.String triggerName, java.lang.String tableName, java.lang.String[] columnNames, java.lang.Object[] oldRow, java.lang.Object[] newRow)
The method invoked upon each triggered action.
-
-
-
Field Detail
-
INSERT_AFTER
static final int INSERT_AFTER
- See Also:
- Constant Field Values
-
DELETE_AFTER
static final int DELETE_AFTER
- See Also:
- Constant Field Values
-
UPDATE_AFTER
static final int UPDATE_AFTER
- See Also:
- Constant Field Values
-
INSERT_AFTER_ROW
static final int INSERT_AFTER_ROW
- See Also:
- Constant Field Values
-
DELETE_AFTER_ROW
static final int DELETE_AFTER_ROW
- See Also:
- Constant Field Values
-
UPDATE_AFTER_ROW
static final int UPDATE_AFTER_ROW
- See Also:
- Constant Field Values
-
INSERT_BEFORE_ROW
static final int INSERT_BEFORE_ROW
- See Also:
- Constant Field Values
-
DELETE_BEFORE_ROW
static final int DELETE_BEFORE_ROW
- See Also:
- Constant Field Values
-
UPDATE_BEFORE_ROW
static final int UPDATE_BEFORE_ROW
- See Also:
- Constant Field Values
-
-
Method Detail
-
fire
default void fire(int type, java.lang.String triggerName, java.lang.String tableName, java.lang.String[] columnNames, java.lang.Object[] oldRow, java.lang.Object[] newRow)
The method invoked upon each triggered action.type contains the integer index id for trigger type, e.g. TriggerDef.INSERT_AFTER
For all triggers defined as default FOR EACH STATEMENT both oldRow and newRow are null.
For triggers defined as FOR EACH ROW, the following will apply:
When UPDATE triggers are fired, oldRow contains the existing values of the table row and newRow contains the new values.
For INSERT triggers, oldRow is null and newRow contains the table row to be inserted. For DELETE triggers, newRow is null and oldRow contains the table row to be deleted.
For error conditions, users can construct an HsqlException using one of the static methods of org.hsqldb.error.Error with a predefined SQL State from org.hsqldb.error.ErrorCode.
- Parameters:
type
- the type as one of the int values defined in the interfacetriggerName
- the name of the triggertableName
- the name of the table upon which the triggered action is occurringcolumnNames
- names of the columns of the tableoldRow
- the old rownewRow
- the new row- Throws:
org.hsqldb.HsqlException
- the preferred type of exception thrown by the method
-
fire
default void fire(int type, java.lang.String triggerName, java.lang.String tableName, java.lang.Object[] oldRow, java.lang.Object[] newRow)
Old fire method.- Parameters:
type
- the type as one of the int values defined in the interfacetriggerName
- the name of the triggertableName
- the name of the table upon which the triggered action is occurringoldRow
- the old rownewRow
- the new row- Throws:
org.hsqldb.HsqlException
- the preferred type of exception thrown by the method
-
-