01: /*
02:
03: Derby - Class org.apache.derby.catalog.TriggerOldTransitionRows
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (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.catalog;
23:
24: import org.apache.derby.iapi.db.Factory;
25: import org.apache.derby.iapi.db.TriggerExecutionContext;
26: import org.apache.derby.iapi.reference.JDBC20Translation;
27:
28: import java.sql.Connection;
29: import java.sql.Statement;
30: import java.sql.ResultSet;
31: import java.sql.ResultSetMetaData;
32: import java.sql.SQLException;
33: import java.sql.SQLWarning;
34: import java.math.BigDecimal;
35:
36: /**
37: * Provides information about a set of rows before a trigger action
38: * changed them.
39: *
40: *
41: * <p>
42: * This class implements only JDBC 1.2, not JDBC 2.0. You cannot
43: * compile this class with JDK1.2, since it implements only the
44: * JDBC 1.2 ResultSet interface and not the JDBC 2.0 ResultSet
45: * interface. You can only use this class in a JDK 1.2 runtime
46: * environment if no JDBC 2.0 calls are made against it.
47: *
48: * @author jamie
49: */
50: public class TriggerOldTransitionRows extends
51: org.apache.derby.vti.UpdatableVTITemplate {
52:
53: private ResultSet resultSet;
54:
55: /**
56: * Construct a VTI on the trigger's old row set.
57: * The old row set is the before image of the rows
58: * that are changed by the trigger. For a trigger
59: * on a delete, this is all the rows that are deleted.
60: * For a trigger on an update, this is the rows before
61: * they are updated. For an insert, this throws an
62: * exception.
63: *
64: * @exception SQLException thrown if no trigger active
65: */
66: public TriggerOldTransitionRows() throws SQLException {
67: TriggerExecutionContext tec = Factory
68: .getTriggerExecutionContext();
69: if (tec == null) {
70: throw new SQLException("There are no active triggers",
71: "38000");
72: }
73: resultSet = tec.getOldRowSet();
74:
75: if (resultSet == null) {
76: throw new SQLException(
77: "There is no old transition rows result set for this trigger",
78: "38000");
79: }
80: }
81:
82: public ResultSet executeQuery() {
83: return resultSet;
84: }
85:
86: public int getResultSetConcurrency() {
87: return JDBC20Translation.CONCUR_READ_ONLY;
88: }
89:
90: public void close() throws SQLException {
91: resultSet.close();
92: }
93: }
|