001: /*
002:
003: Derby - Class org.apache.derby.iapi.sql.Statement
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.sql;
023:
024: import org.apache.derby.iapi.error.StandardException;
025: import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
026: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
027:
028: /**
029: * The Statement interface provides a way of giving a statement to the
030: * language module, preparing the statement, and executing it. It also
031: * provides some support for stored statements. Simple, non-stored,
032: * non-parameterized statements can be executed with the execute() method.
033: * Parameterized statements must use prepare(). To get the stored query
034: * plan for a statement, use get().
035: * <p>
036: * This interface will have different implementations for the execution-only
037: * and compile-and-execute versions of the product. In the execution-only
038: * version, some of the methods will do nothing but raise exceptions to
039: * indicate that they are not implemented.
040: * <p>
041: * There is a Statement factory in the Connection interface in the Database
042: * module, which uses the one provided in LanguageFactory.
043: *
044: * @author Jeff Lichtman
045: */
046: public interface Statement {
047:
048: /**
049: * Generates an execution plan without executing it.
050: *
051: * @return A PreparedStatement that allows execution of the execution
052: * plan.
053: * @exception StandardException Thrown if this is an
054: * execution-only version of the module (the prepare() method
055: * relies on compilation).
056: */
057: PreparedStatement prepare(LanguageConnectionContext lcc)
058: throws StandardException;
059:
060: /**
061: * Generates an execution plan without executing it.
062: *
063: * @param lcc the language connection context
064: * @param allowInternalSyntax If this statement is for a metadata call then
065: * we will allow internal sql syntax on such statement. This internal
066: * sql syntax is not available to a user sql statement.
067: *
068: * @return A PreparedStatement that allows execution of the execution
069: * plan.
070: * @exception StandardException Thrown if this is an
071: * execution-only version of the module (the prepare() method
072: * relies on compilation).
073: */
074: PreparedStatement prepare(LanguageConnectionContext lcc,
075: boolean allowInternalSyntax) throws StandardException;
076:
077: /**
078: * Generates an execution plan given a set of named parameters.
079: * For generating a storable prepared statement (which
080: * has some extensions over a standard prepared statement).
081: *
082: * @param lcc Compiler state variable.
083: * @param ps Prepared statement
084: * @param paramDefaults Default parameter values to use for
085: * optimization
086: * @param spsSchema schema of the stored prepared statement
087: *
088: * @return A Storable PreparedStatement that allows execution of the execution
089: * plan.
090: * @exception StandardException Thrown if this is an
091: * execution-only version of the module (the prepare() method
092: * relies on compilation).
093: */
094: public PreparedStatement prepareStorable(
095: LanguageConnectionContext lcc, PreparedStatement ps,
096: Object[] paramDefaults, SchemaDescriptor spsSchema,
097: boolean internalSQL) throws StandardException;
098:
099: /**
100: * Return the SQL string that this statement is for.
101: *
102: * @return the SQL string this statement is for.
103: */
104: String getSource();
105: }
|