KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > db > TriggerExecutionContext


1 /*
2
3    Derby - Class org.apache.derby.iapi.db.TriggerExecutionContext
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.db;
23
24 import java.sql.ResultSet JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import org.apache.derby.catalog.UUID;
27
28 /**
29  * A trigger execution context holds information that is
30  * available from the context of a trigger invocation.
31  */

32 public interface TriggerExecutionContext
33 {
34     /**
35      * Return value from </I>getEventType()</I> for
36      * an update trigger.
37      */

38     public static final int UPDATE_EVENT = 1;
39
40     /**
41      * Return value from </I>getEventType()</I> for
42      * a delete trigger.
43      */

44     public static final int DELETE_EVENT = 2;
45
46     /**
47      * Return value from </I>getEventType()</I> for
48      * an insert trigger.
49      */

50     public static final int INSERT_EVENT = 3;
51
52
53     /**
54      * Get the target table name upon which the
55      * trigger event is declared.
56      *
57      * @return the target table
58      */

59     public String JavaDoc getTargetTableName();
60
61     /**
62      * Get the target table UUID upon which the
63      * trigger event is declared.
64      *
65      * @return the uuid of the target table
66      */

67     public UUID getTargetTableId();
68
69     /**
70      * Get the type for the event that caused the
71      * trigger to fire.
72      *
73      * @return the event type (e.g. UPDATE_EVENT)
74      */

75     public int getEventType();
76
77     /**
78      * Get the text of the statement that caused the
79      * trigger to fire.
80      *
81      * @return the statement text.
82      */

83     public String JavaDoc getEventStatementText();
84
85     /**
86      * Get the columns that have been modified by the statement
87      * that caused this trigger to fire. If all columns are
88      * modified, will return null (e.g. for INSERT or DELETE
89      * return null).
90      *
91      * @return an array of Strings
92      */

93     public String JavaDoc[] getModifiedColumns();
94
95     /**
96      * Find out if a column was changed, by column name.
97      *
98      * @param columnName the column to check
99      *
100      * @return true if the column was modified by this statement.
101      * Note that this will always return true for INSERT
102      * and DELETE regardless of the column name passed in.
103      */

104     public boolean wasColumnModified(String JavaDoc columnName);
105
106     /**
107      * Find out if a column was changed, by column number
108      *
109      * @param columnNumber the column to check
110      *
111      * @return true if the column was modified by this statement.
112      * Note that this will always return true for INSERT
113      * and DELETE regardless of the column name passed in.
114      */

115     public boolean wasColumnModified(int columnNumber);
116
117     /**
118      * Returns a result set of the old (before) images of the changed rows.
119      * For a row trigger, this result set will have a single row. For
120      * a statement trigger, this result set has every row that has
121      * changed or will change. If a statement trigger does not affect
122      * a row, then the result set will be empty (i.e. ResultSet.next()
123      * will return false).
124      * <p>
125      * Will return null if the call is inapplicable for the trigger
126      * that is currently executing. For example, will return null if called
127      * during a the firing of an INSERT trigger.
128      *
129      * @return the ResultSet containing before images of the rows
130      * changed by the triggering event. May return null.
131      *
132      * @exception SQLException if called after the triggering event has
133      * completed
134      */

135     public ResultSet JavaDoc getOldRowSet() throws SQLException JavaDoc;
136
137     /**
138      * Returns a result set of the new (after) images of the changed rows.
139      * For a row trigger, this result set will have a single row. For
140      * a statement trigger, this result set has every row that has
141      * changed or will change. If a statement trigger does not affect
142      * a row, then the result set will be empty (i.e. ResultSet.next()
143      * will return false).
144      * <p>
145      * Will return null if the call is inapplicable for the trigger
146      * that is currently executing. For example, will return null if
147      * called during the firing of a DELETE trigger.
148      *
149      * @return the ResultSet containing after images of the rows
150      * changed by the triggering event. May return null.
151      *
152      * @exception SQLException if called after the triggering event has
153      * completed
154      */

155     public ResultSet JavaDoc getNewRowSet() throws SQLException JavaDoc;
156
157     /**
158      * Like getOldRowSet(), but returns a result set positioned
159      * on the first row of the before (old) result set. Used as a convenience
160      * to get a column for a row trigger. Equivalent to getOldRowSet()
161      * followed by next().
162      * <p>
163      * Will return null if the call is inapplicable for the trigger
164      * that is currently executing. For example, will return null if called
165      * during a the firing of an INSERT trigger.
166      *
167      * @return the ResultSet positioned on the old row image. May
168      * return null.
169      *
170      * @exception SQLException if called after the triggering event has
171      * completed
172      */

173     public ResultSet JavaDoc getOldRow() throws SQLException JavaDoc;
174
175     /**
176      * Like getNewRowSet(), but returns a result set positioned
177      * on the first row of the after (new) result set. Used as a convenience
178      * to get a column for a row trigger. Equivalent to getNewRowSet()
179      * followed by next().
180      * <p>
181      * Will return null if the call is inapplicable for the trigger
182      * that is currently executing. For example, will return null if
183      * called during the firing of a DELETE trigger.
184      *
185      * @return the ResultSet positioned on the new row image. May
186      * return null.
187      *
188      * @exception SQLException if called after the triggering event has
189      * completed
190      */

191     public ResultSet JavaDoc getNewRow() throws SQLException JavaDoc;
192 }
193
Popular Tags