com.caucho.db.sql
Class Query

java.lang.Object
  extended by com.caucho.db.sql.Query
Direct Known Subclasses:
CreateQuery, SelectQuery, TempQuery

public abstract class Query
extends java.lang.Object


Field Summary
protected  Expr _whereExpr
           
 
Constructor Summary
protected Query(Database db, java.lang.String sql)
           
protected Query(Database db, java.lang.String sql, com.caucho.db.sql.FromItem[] fromItems)
           
 
Method Summary
protected  void bind()
          Binds the query.
protected  Expr bind(java.lang.String tableName, java.lang.String columnName)
          Returns a bound expression for the specified table.column.
 void clearParameters()
          Clears the paramters.
abstract  void execute(QueryContext queryCtx, Transaction xa)
          Executes the query.
protected  void freeRows(TableIterator[] rows, int rowLength)
          Frees any blocks for the rows.
protected  void generateWhere(Expr whereExpr)
          Optimize the where and order the from items.
 Database getDatabase()
          Returns the owning database.
 int getDataFields()
          Returns the number of temporary data fields.
 com.caucho.db.sql.FromItem[] getFromItems()
          Returns any from items.
 java.util.ArrayList<com.caucho.db.sql.SubSelectParamExpr> getParamExprs()
          Returns the param exprs.
 Query getParent()
          Gets the parent query
 SubSelectExpr getSubSelect()
          Gets the parent sub-select.
 Expr[] getWhereExprs()
          Returns the where exprs
 boolean isGroup()
          Sets true for group operations
 boolean isReadOnly()
           
 boolean isSelect()
          Returns true for select queries.
protected  boolean nextTuple(TableIterator[] rows, int rowLength, QueryContext queryContext, Transaction xa)
          Returns the next tuple from the query.
 void setBinaryStream(int index, java.io.InputStream is, int length)
          Sets the indexed parameter as a binary stream
 void setBoolean(int index, boolean value)
          Sets the indexed parameter as a boolean.
 void setBytes(int index, byte[] bytes)
          Sets the indexed parameter as a bytes
 void setDataFields(int fieldCount)
          Sets the number of temporary data fields.
 void setDate(int index, long value)
          Sets the indexed parameter as a date value.
 void setDouble(int index, double value)
          Sets the indexed parameter as a double.
protected  void setFromItems(java.util.ArrayList<com.caucho.db.sql.FromItem> fromItems)
          Sets from items.
protected  void setFromItems(com.caucho.db.sql.FromItem[] fromItems)
          Sets from items.
 void setGroup(boolean isGroup)
          Sets the current number of group fields.
 void setLimit(int limit)
          Sets the maximum entires
 void setLong(int index, long value)
          Sets the indexed parameter as a long.
 void setParams(com.caucho.db.sql.ParamExpr[] params)
          Sets the params.
 void setParent(Query query)
          Sets the parent query
 void setString(int index, java.lang.String value)
          Sets the indexed parameter as a string.
 void setSubSelect(SubSelectExpr subSelect)
          Sets the parent sub-select.
 void setWhereExpr(Expr expr)
          Sets the where expr.
protected  void setWhereExprs(Expr[] whereExprs)
          Sets the where exprs.
protected  boolean start(TableIterator[] rows, int rowLength, QueryContext queryContext, Transaction xa)
          Starts the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_whereExpr

protected Expr _whereExpr
Constructor Detail

Query

protected Query(Database db,
                java.lang.String sql)

Query

protected Query(Database db,
                java.lang.String sql,
                com.caucho.db.sql.FromItem[] fromItems)
Method Detail

getDatabase

public Database getDatabase()
Returns the owning database.


setParent

public void setParent(Query query)
Sets the parent query


getParent

public Query getParent()
Gets the parent query


setSubSelect

public void setSubSelect(SubSelectExpr subSelect)
Sets the parent sub-select.


getSubSelect

public SubSelectExpr getSubSelect()
Gets the parent sub-select.


getDataFields

public int getDataFields()
Returns the number of temporary data fields.


setDataFields

public void setDataFields(int fieldCount)
Sets the number of temporary data fields.


setLimit

public void setLimit(int limit)
Sets the maximum entires


getFromItems

public com.caucho.db.sql.FromItem[] getFromItems()
Returns any from items.


setFromItems

protected void setFromItems(com.caucho.db.sql.FromItem[] fromItems)
Sets from items.


setFromItems

protected void setFromItems(java.util.ArrayList<com.caucho.db.sql.FromItem> fromItems)
Sets from items.


setWhereExpr

public void setWhereExpr(Expr expr)
Sets the where expr.


getWhereExprs

public Expr[] getWhereExprs()
Returns the where exprs


setWhereExprs

protected void setWhereExprs(Expr[] whereExprs)
Sets the where exprs.


setParams

public void setParams(com.caucho.db.sql.ParamExpr[] params)
Sets the params.


getParamExprs

public java.util.ArrayList<com.caucho.db.sql.SubSelectParamExpr> getParamExprs()
Returns the param exprs.


isSelect

public boolean isSelect()
Returns true for select queries.


isReadOnly

public boolean isReadOnly()

setGroup

public void setGroup(boolean isGroup)
Sets the current number of group fields.


isGroup

public boolean isGroup()
Sets true for group operations


bind

protected void bind()
             throws java.sql.SQLException
Binds the query.

Throws:
java.sql.SQLException

generateWhere

protected void generateWhere(Expr whereExpr)
                      throws java.sql.SQLException
Optimize the where and order the from items.

Throws:
java.sql.SQLException

bind

protected Expr bind(java.lang.String tableName,
                    java.lang.String columnName)
             throws java.sql.SQLException
Returns a bound expression for the specified table.column.

Throws:
java.sql.SQLException

clearParameters

public void clearParameters()
Clears the paramters.


setBoolean

public void setBoolean(int index,
                       boolean value)
Sets the indexed parameter as a boolean.


setString

public void setString(int index,
                      java.lang.String value)
Sets the indexed parameter as a string.


setLong

public void setLong(int index,
                    long value)
Sets the indexed parameter as a long.


setDouble

public void setDouble(int index,
                      double value)
Sets the indexed parameter as a double.


setDate

public void setDate(int index,
                    long value)
Sets the indexed parameter as a date value.


setBinaryStream

public void setBinaryStream(int index,
                            java.io.InputStream is,
                            int length)
Sets the indexed parameter as a binary stream


setBytes

public void setBytes(int index,
                     byte[] bytes)
Sets the indexed parameter as a bytes


execute

public abstract void execute(QueryContext queryCtx,
                             Transaction xa)
                      throws java.sql.SQLException
Executes the query.

Throws:
java.sql.SQLException

start

protected boolean start(TableIterator[] rows,
                        int rowLength,
                        QueryContext queryContext,
                        Transaction xa)
                 throws java.sql.SQLException
Starts the query.

Throws:
java.sql.SQLException

nextTuple

protected boolean nextTuple(TableIterator[] rows,
                            int rowLength,
                            QueryContext queryContext,
                            Transaction xa)
                     throws java.sql.SQLException
Returns the next tuple from the query.

Throws:
java.sql.SQLException

freeRows

protected void freeRows(TableIterator[] rows,
                        int rowLength)
Frees any blocks for the rows.