1 /* 2 3 Derby - Class org.apache.derby.iapi.sql.Statement 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; 23 24 import org.apache.derby.iapi.error.StandardException; 25 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 26 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 27 28 /** 29 * The Statement interface provides a way of giving a statement to the 30 * language module, preparing the statement, and executing it. It also 31 * provides some support for stored statements. Simple, non-stored, 32 * non-parameterized statements can be executed with the execute() method. 33 * Parameterized statements must use prepare(). To get the stored query 34 * plan for a statement, use get(). 35 * <p> 36 * This interface will have different implementations for the execution-only 37 * and compile-and-execute versions of the product. In the execution-only 38 * version, some of the methods will do nothing but raise exceptions to 39 * indicate that they are not implemented. 40 * <p> 41 * There is a Statement factory in the Connection interface in the Database 42 * module, which uses the one provided in LanguageFactory. 43 * 44 * @author Jeff Lichtman 45 */ 46 public interface Statement 47 { 48 49 /** 50 * Generates an execution plan without executing it. 51 * 52 * @return A PreparedStatement that allows execution of the execution 53 * plan. 54 * @exception StandardException Thrown if this is an 55 * execution-only version of the module (the prepare() method 56 * relies on compilation). 57 */ 58 PreparedStatement prepare(LanguageConnectionContext lcc) throws StandardException; 59 /** 60 * Generates an execution plan without executing it. 61 * 62 * @param lcc the language connection context 63 * @param allowInternalSyntax If this statement is for a metadata call then 64 * we will allow internal sql syntax on such statement. This internal 65 * sql syntax is not available to a user sql statement. 66 * 67 * @return A PreparedStatement that allows execution of the execution 68 * plan. 69 * @exception StandardException Thrown if this is an 70 * execution-only version of the module (the prepare() method 71 * relies on compilation). 72 */ 73 PreparedStatement prepare(LanguageConnectionContext lcc, boolean allowInternalSyntax) throws StandardException; 74 75 /** 76 * Generates an execution plan given a set of named parameters. 77 * For generating a storable prepared statement (which 78 * has some extensions over a standard prepared statement). 79 * 80 * @param lcc Compiler state variable. 81 * @param ps Prepared statement 82 * @param paramDefaults Default parameter values to use for 83 * optimization 84 * @param spsSchema schema of the stored prepared statement 85 * 86 * @return A Storable PreparedStatement that allows execution of the execution 87 * plan. 88 * @exception StandardException Thrown if this is an 89 * execution-only version of the module (the prepare() method 90 * relies on compilation). 91 */ 92 public PreparedStatement prepareStorable 93 ( 94 LanguageConnectionContext lcc, 95 PreparedStatement ps, 96 Object[] paramDefaults, 97 SchemaDescriptor spsSchema, 98 boolean internalSQL 99 ) 100 throws StandardException; 101 102 /** 103 * Return the SQL string that this statement is for. 104 * 105 * @return the SQL string this statement is for. 106 */ 107 String getSource(); 108 } 109