package ModSQL;
import java.sql.SQLException;

/* $Id: Query.java,v 1.5 2003/05/29 05:48:45 cvs Exp $
 *
 * Copyright (c) 2003 Chris Studholme <chris.studholme@utoronto.ca>
 *
 * May be copied or modified under the terms of the GNU General Public
 * License.  See COPYING for more information.
 */

/**
 * Interface for the various SQL query classes.
 *
 * @author chris.studholme@utoronto.ca
 */
interface Query {

  /**
   * Optimize the query before executing it.
   *
   * @throws SQLException if an error occurs
   */
  public void optimize() throws SQLException;

  /**
   * Return human readable version of optimized query.
   *
   * @param with_brackets bracket query expression
   * @return human-readable text version of query
   */
  public String toString(boolean with_brackets);

  /**
   * Execute optimized query.
   *
   * @return update count; -1 if update count is not applicable
   * @throws SQLException if an error occurs
   */
  public int execute() throws SQLException;

  /**
   * Close the query and free all resources in use.
   *
   * @throws SQLException if an error occurs
   */
  public void close() throws SQLException;
}
