KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > sql > conn > StatementContext


1 /*
2
3    Derby - Class org.apache.derby.iapi.sql.conn.StatementContext
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.sql.conn;
23
24 import org.apache.derby.iapi.services.context.Context;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
29
30 import org.apache.derby.iapi.sql.Activation;
31 import org.apache.derby.iapi.sql.PreparedStatement;
32 import org.apache.derby.iapi.sql.ResultSet;
33 import org.apache.derby.iapi.sql.ParameterValueSet;
34
35 import org.apache.derby.iapi.sql.depend.Dependency;
36
37 import org.apache.derby.iapi.types.DataValueFactory;
38 import org.apache.derby.iapi.sql.LanguageFactory;
39
40 /**
41  * StatementContext keeps the context for a statement.
42  */

43 public interface StatementContext extends Context {
44
45     /**
46      * Mark this context as being in use.
47      *
48      * @param inTrigger true if the parent started in the context of a trigger
49      * @param isAtomic true if the statement must be executed
50      * atomically
51      * @param isForReadOnly true if the statement is for producing non-updatable
52      * resultset
53      * @param stmtText the text of the statement. Needed for any language
54      * statement (currently, for any statement that can cause a trigger
55      * to fire). Please set this unless you are some funky jdbc setXXX
56      * method or something.
57      * @param pvs parameter value set, if it has one
58      * @param timeoutMillis timeout value for the statement, in milliseconds.
59      * Zero means no timeout.
60      */

61     public void setInUse(boolean inTrigger, boolean isAtomic, boolean isForReadOnly,
62              String JavaDoc stmtText, ParameterValueSet pvs, long timeoutMillis);
63
64     /**
65      * Mark this context as not in use. This is important because we
66      * always leave the top statement context on the stack, and we don't
67      * want to clean it up if a statement level exception happens while the
68      * context is not in use.
69      */

70     public void clearInUse();
71
72     /**
73      * Set a save point for the current statement.
74      * NOTE: This needs to be off of the StatementContext so that it gets
75      * cleared on a statement error.
76      *
77      * @exception StandardException Thrown on error
78      */

79     public void setSavePoint() throws StandardException;
80
81     /**
82      * If this statement context has a savepoint, then
83      * it is reset to the current point. Otherwise, it
84      * is a noop.
85      *
86      * @exception StandardException Thrown on error
87      */

88     public void resetSavePoint() throws StandardException;
89
90     /**
91      * Clear the save point for the current statement.
92      *
93      * @exception StandardException Thrown on error
94      */

95     public void clearSavePoint() throws StandardException;
96
97     /**
98      * Set the top ResultSet in the ResultSet tree for close down on
99      * an error.
100      *
101      * @param topResultSet The top ResultSet in the ResultSet tree
102      * @param subqueryTrackingArray (Sparse) of tops of subquery ResultSet trees
103      *
104      * @exception StandardException Thrown on error
105      */

106     public void setTopResultSet(ResultSet topResultSet,
107                                 NoPutResultSet[] subqueryTrackingArray)
108          throws StandardException;
109
110     /**
111      * Set the appropriate entry in the subquery tracking array for
112      * the specified subquery.
113      * Useful for closing down open subqueries on an exception.
114      *
115      * @param subqueryNumber The subquery # for this subquery
116      * @param subqueryResultSet The NoPutResultSet at the top of the subquery
117      * @param numSubqueries The total # of subqueries in the entire query
118      *
119      * @exception StandardException Thrown on error
120      */

121     public void setSubqueryResultSet(int subqueryNumber,
122                                      NoPutResultSet subqueryResultSet,
123                                      int numSubqueries)
124         throws StandardException;
125
126     /**
127      * Get the subquery tracking array for this query.
128      * (Useful for runtime statistics.)
129      *
130      * @return NoPutResultSet[] The (sparse) array of tops of subquery ResultSet trees
131      * @exception StandardException Thrown on error
132      */

133     public NoPutResultSet[] getSubqueryTrackingArray()
134         throws StandardException;
135
136
137     /**
138      * Track a Dependency within this StatementContext.
139      * (We need to clear any dependencies added within this
140      * context on an error.
141      *
142      * @param dy The dependency to track.
143      *
144      * @exception StandardException Thrown on error
145      */

146     public void addDependency(Dependency dy)
147         throws StandardException;
148
149     /**
150       * Reports whether this StatementContext is on the context stack.
151       *
152       * @return true if this StatementContext is on the context stack. false otherwise.
153       */

154     public boolean onStack();
155
156     /**
157      * Returns whether we started from within the context of a trigger
158      * or not.
159      *
160      * @return true if we are in a trigger context
161      */

162     public boolean inTrigger();
163     
164     /**
165      * Indicates whether the statement needs to be executed atomically
166      * or not, i.e., whether a commit/rollback is permitted by a
167      * connection nested in this statement.
168      *
169      * @return true if needs to be atomic
170      */

171     public boolean isAtomic();
172
173     /**
174      * Is this statement context in use or not.
175      *
176      * @return true if in use
177      */

178     public boolean inUse();
179
180     /**
181      * Is this statement for a read only, non-updatable ResultSet
182      * @return true if the statement is for creating a
183      * read only, non-updatable ResultSet
184      */

185     public boolean isForReadOnly();
186     
187     
188     /**
189      * Checks if the statement which has allocated this statement context
190      * should cancel its execution.
191      *
192      * @return true if the statement execution should be cancelled.
193      **/

194     public boolean isCancelled();
195
196     /**
197      * Indicate that the statement which has allocated this statement
198      * context should cancel its execution.
199      * Usually called as a consequence of Statement.cancel() or a query timeout
200      * set with Statement.setQueryTimeout().
201      */

202     public void cancel();
203
204     /**
205      * Return the text of the current statement.
206      * Note that this may be null. It is currently
207      * not set up correctly for ResultSets that aren't
208      * single row result sets (e.g SELECT)
209      * and setXXXX/getXXXX jdbc methods.
210      *
211      * @return the statement text
212      */

213     public String JavaDoc getStatementText();
214
215     /**
216         Set the level of SQL allowed in this and subsequent
217         nested statements due to a routine call. Value must be one of
218         RoutineAliasInfo.{MODIFIES_SQL_DATA, READS_SQL_DATA, CONTAINS_SQL, NO_SQL}
219
220         @param force set to true to override more restrictive setting. Used to
221         reset the permissions after a function call.
222
223     */

224     public void setSQLAllowed(short allow, boolean force);
225
226     /**
227         Get the setting of the SQL allowed state.
228     */

229     public short getSQLAllowed();
230
231
232     /**
233         Set to indicate statement is system code.
234         For example a system procedure, view, function etc.
235     */

236     public void setSystemCode();
237
238     /**
239         Return true if this statement is system code.
240     */

241     public boolean getSystemCode();
242
243     /**
244         Indicate that, in the event of a statement-level exception,
245         this context is NOT the last one that needs to be rolled
246         back--rather, it is nested within some other statement
247         context, and that other context needs to be rolled back,
248         too.
249     */

250     public void setParentRollback();
251
252 }
253
Popular Tags