KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > catalog > TriggerOldTransitionRows


1 /*
2
3    Derby - Class org.apache.derby.catalog.TriggerOldTransitionRows
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.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 JavaDoc;
29 import java.sql.Statement JavaDoc;
30 import java.sql.ResultSet JavaDoc;
31 import java.sql.ResultSetMetaData JavaDoc;
32 import java.sql.SQLException JavaDoc;
33 import java.sql.SQLWarning JavaDoc;
34 import java.math.BigDecimal JavaDoc;
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 org.apache.derby.vti.UpdatableVTITemplate
51 {
52
53     private ResultSet JavaDoc 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 JavaDoc
67     {
68         TriggerExecutionContext tec = Factory.getTriggerExecutionContext();
69         if (tec == null)
70         {
71             throw new SQLException JavaDoc("There are no active triggers", "38000");
72         }
73         resultSet = tec.getOldRowSet();
74
75         if (resultSet == null)
76         {
77             throw new SQLException JavaDoc("There is no old transition rows result set for this trigger", "38000");
78         }
79     }
80
81        public ResultSet JavaDoc executeQuery() {
82            return resultSet;
83        }
84         
85        public int getResultSetConcurrency() {
86             return JDBC20Translation.CONCUR_READ_ONLY;
87        }
88        public void close() throws SQLException JavaDoc {
89            resultSet.close();
90        }
91 }
92
Popular Tags