2004.04.29


com.jdc.rdb.sql.dml.select
Class Select

java.lang.Object
  |
  +--com.jdc.lang.Object
        |
        +--com.jdc.rdb.sql.SQL
              |
              +--com.jdc.rdb.sql.dml.DML
                    |
                    +--com.jdc.rdb.sql.dml.select.Select
All Implemented Interfaces:
Serializable, Statement

public class Select
extends DML

Select represents a Data Manipulation Language Select SQL statement.

Version:
1.5
Author:
Jay Damon
See Also:
Rows, Columns, From, Correlation, Where, GroupBy, Having, OrderBy, With, Serialized Form

Nested Class Summary
 class Select.Status
          Status is the SQL status class for a database structured query language (SQL) data manipulation language (DML) Select statement object.
 
Field Summary
static String COMMAND
          The Select statement command keyword.
 
Fields inherited from class com.jdc.rdb.sql.dml.DML
sql
 
Fields inherited from class com.jdc.lang.Object
string
 
Constructor Summary
Select()
          Constructs a new Select statement object.
Select(Table table)
          Constructs a new Select statement object for the specified Database Table.
 
Method Summary
 SelectStatus execute()
          Executes the Select statement and returns an SelectStatus object.
 SQLStatus execute(boolean displayMessages)
          Executes the requested SQL SELECT statement.
 Columns getColumns()
          Returns the Columns clause for this Select statement.
 From getFrom()
          Returns the From clause for this Select statement.
 GroupBy getGroupBy()
          Returns the GroupBy clause for this Select statement.
 Having getHaving()
          Returns the Having clause for this Select statement.
 OrderBy getOrderBy()
          Returns the OrderBy clause for this Select statement.
 Rows getRows()
          Returns the Rows clause for this Select statement.
 Where getWhere()
          Returns the Where clause for this Select statement.
protected  boolean isValid()
          Returns true if the Select statement is valid.
 Select set(SelectClause clause)
          Sets a SelectClause for this Select statement.
 Select setAll()
          Adds the optional ALL keyword to the Select statement.
 Select setColumn(Column column)
          Adds a table Column name to select.
 Select setDistinct()
          Adds the optional DISTINCT keyword to the Select statement.
 Select setGroupBy(Column column)
          Adds a table Column name to group by.
 Select setOrderBy(Column column)
          Adds a table Column name to order by plus the sort order.
 Select setOrderBy(Column column, Order order)
          Adds a table Column name to order by plus the sort order.
 Select setWhere(Column column, Comparison comparison, int value)
          Sets a search condition for the specified table Column, Comparison operator, and int value.
 Select setWhere(Column column, Comparison comparison, Object value)
          Sets a search condition for the specified table Column, Comparison operator, and Object value.
 Select setWhere(Column column, int value)
          Sets a search condition for the specified table Column and int value.
 Select setWhere(Column column, Object value)
          Sets a search condition for the specified table Column and Object value.
 
Methods inherited from class com.jdc.rdb.sql.dml.DML
finalize, getColumn, getConnection, getTable, setTable
 
Methods inherited from class com.jdc.rdb.sql.SQL
addClause, getClause, getCommand, getStatement, setCommand, setConnection, setStatement, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMAND

public static final String COMMAND
The Select statement command keyword.

See Also:
Constant Field Values
Constructor Detail

Select

public Select()
Constructs a new Select statement object.


Select

public Select(Table table)
Constructs a new Select statement object for the specified Database Table.

Throws:
SQLInvalidException - No table definition is specified.
Method Detail

execute

public SelectStatus execute()
Executes the Select statement and returns an SelectStatus object.

Returns:
The Select statement status.

execute

public SQLStatus execute(boolean displayMessages)
Executes the requested SQL SELECT statement.

Overrides:
execute in class SQL
Returns:
Status The SQL SELECT statement execution status.

getColumns

public Columns getColumns()
Returns the Columns clause for this Select statement.

Returns:
The Select statement Columns clause.

getFrom

public From getFrom()
Returns the From clause for this Select statement.

Returns:
The Select statement From clause.

getGroupBy

public GroupBy getGroupBy()
Returns the GroupBy clause for this Select statement.

Returns:
The Select statement GroupBy clause.

getHaving

public Having getHaving()
Returns the Having clause for this Select statement.

Returns:
The Select statement Having clause.

getOrderBy

public OrderBy getOrderBy()
Returns the OrderBy clause for this Select statement.

Returns:
The Select statement OrderBy clause.

getRows

public Rows getRows()
Returns the Rows clause for this Select statement.

Returns:
The Select statement Rows clause.

getWhere

public Where getWhere()
Returns the Where clause for this Select statement.

Returns:
The Select statement Where clause.

isValid

protected boolean isValid()
Returns true if the Select statement is valid.

Overrides:
isValid in class SQL
Returns:
True if the SQL statement is valid.
False if the SQL statement is not valid

set

public Select set(SelectClause clause)
Sets a SelectClause for this Select statement. Use this method to specify a custom Select clause.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No SELECT statement clause is specified.

setAll

public Select setAll()
Adds the optional ALL keyword to the Select statement. This keyword retains all rows of the final result table and does not eliminate (redundant) duplicates. This is the default.

Returns:
This Select statement object.
See Also:
setDistinct

setColumn

public Select setColumn(Column column)
Adds a table Column name to select. These values are used to create the Columns clause for this statement.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setDistinct

public Select setDistinct()
Adds the optional DISTINCT keyword to the Select statement. This keyword eliminates all but one of each set of duplicate rows of the final result table.

Two rows are duplicates of one another only if each value in the first is equal to the corresponding value of the second. For determining duplicates, two null values are considered equal.

Returns:
This Select statement object.
See Also:
setAll

setGroupBy

public Select setGroupBy(Column column)
Adds a table Column name to group by. These values are used to create the GroupBy clause for this statement.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setOrderBy

public Select setOrderBy(Column column)
Adds a table Column name to order by plus the sort order. These values are used to create the OrderBy clause for this statement. A sort Order of ASCENDING is implied.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setOrderBy

public Select setOrderBy(Column column,
                         Order order)
Adds a table Column name to order by plus the sort order. These values are used to create the OrderBy clause for this statement. A Comparison operator of EQUAL, i.e. "=", is implied.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setWhere

public Select setWhere(Column column,
                       int value)
Sets a search condition for the specified table Column and int value. These values are used to create the Where clause for this statement. A Comparison operator of EQUAL, i.e. "=", is implied.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setWhere

public Select setWhere(Column column,
                       Object value)
Sets a search condition for the specified table Column and Object value. These values are used to create the Where clause for this statement. A Comparison operator of EQUAL, i.e. "=", is implied.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setWhere

public Select setWhere(Column column,
                       Comparison comparison,
                       int value)
Sets a search condition for the specified table Column, Comparison operator, and int value. These values are used to create the Where clause for this statement. Refer to the Comparison operator class for a list of valid comparison operators.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setWhere

public Select setWhere(Column column,
                       Comparison comparison,
                       Object value)
Sets a search condition for the specified table Column, Comparison operator, and Object value. These values are used to create the Where clause for this statement. Refer to the Comparison operator class for a list of valid comparison operators.

Returns:
This Select statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.