01: /*
02:
03: Derby - Class org.apache.derby.catalog.TriggerNewTransitionRows
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 about a a set of new rows created by a
38: * trigger action.
39: *
40: * <p>
41: * This class implements only JDBC 1.2, not JDBC 2.0. You cannot
42: * compile this class with JDK1.2, since it implements only the
43: * JDBC 1.2 ResultSet interface and not the JDBC 2.0 ResultSet
44: * interface. You can only use this class in a JDK 1.2 runtime
45: * environment if no JDBC 2.0 calls are made against it.
46: *
47: * @author jamie
48: */
49: public final class TriggerNewTransitionRows extends
50: org.apache.derby.vti.UpdatableVTITemplate {
51:
52: private ResultSet resultSet;
53:
54: /**
55: * Construct a VTI on the trigger's new row set.
56: * The new row set is the after image of the rows
57: * that are changed by the trigger. For a trigger
58: * on a delete, this throws an exception.
59: * For a trigger on an update, this is the rows after
60: * they are updated. For an insert, this is the rows
61: * that are inserted.
62: *
63: * @exception SQLException thrown if no trigger active
64: */
65: public TriggerNewTransitionRows() throws SQLException {
66: TriggerExecutionContext tec = Factory
67: .getTriggerExecutionContext();
68: if (tec == null) {
69: throw new SQLException("There are no active triggers",
70: "38000");
71: }
72: resultSet = tec.getNewRowSet();
73:
74: if (resultSet == null) {
75: throw new SQLException(
76: "There is no new transition rows result set for this trigger",
77: "38000");
78: }
79: }
80:
81: public ResultSetMetaData getMetaData() throws SQLException {
82: return resultSet.getMetaData();
83: }
84:
85: public ResultSet executeQuery() {
86: return resultSet;
87: }
88:
89: public int getResultSetConcurrency() {
90: return JDBC20Translation.CONCUR_READ_ONLY;
91: }
92:
93: public void close() throws SQLException {
94: resultSet.close();
95: }
96: }
|