KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.catalog.TriggerNewTransitionRows
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 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 org.apache.derby.vti.UpdatableVTITemplate
50 {
51
52     private ResultSet JavaDoc 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 JavaDoc
66     {
67         TriggerExecutionContext tec = Factory.getTriggerExecutionContext();
68         if (tec == null)
69         {
70             throw new SQLException JavaDoc("There are no active triggers", "38000");
71         }
72         resultSet = tec.getNewRowSet();
73
74         if (resultSet == null)
75         {
76             throw new SQLException JavaDoc("There is no new transition rows result set for this trigger", "38000");
77         }
78     }
79     
80     public ResultSetMetaData JavaDoc getMetaData() throws SQLException JavaDoc
81     {
82         return resultSet.getMetaData();
83     }
84     
85    public ResultSet JavaDoc executeQuery() {
86        return resultSet;
87    }
88     
89    public int getResultSetConcurrency() {
90         return JDBC20Translation.CONCUR_READ_ONLY;
91    }
92    
93    public void close() throws SQLException JavaDoc {
94        resultSet.close();
95    }
96 }
97
Popular Tags