2004.04.29


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

java.lang.Object
  |
  +--com.jdc.lang.Object
        |
        +--com.jdc.rdb.sql.SQLClause
              |
              +--com.jdc.rdb.sql.dml.DMLClause
                    |
                    +--com.jdc.rdb.sql.dml.select.GroupBy
All Implemented Interfaces:
Clause, SelectClause, Serializable

public class GroupBy
extends DMLClause
implements SelectClause

GroupBy represents a Select SQL statement GROUP BY clause. The GROUP BY clause specifies specifies an intermediate result Table that consists of a grouping of the rows of into the result table. The result table is the result of the previous clause of the subselect.

In its simplest form, a GROUP BY clause contains a grouping expression. A grouping expression is an expression used in defining the grouping of the result table. Each column name included in grouping-expression must unambiguously identify a column of the result table.

If the grouping-expression contains varying-length strings with trailing blanks, the values in the group can differ in the number of trailing blanks and may not all have the same length. In that case, a reference to the grouping-expression still specifies only one value for each group, but the value for a group is chosen arbitrarily from the available set of values. Thus, the actual length of the result value is unpredictable.

Reference:
IBM® DB2 Universal Database™ SQL Reference Volume 1 Version 8, Pages 569 thru 576.

Version:
2.0
Author:
Jay Damon
See Also:
Select, Serialized Form

Field Summary
 
Fields inherited from class com.jdc.rdb.sql.dml.DMLClause
sqlClause
 
Fields inherited from class com.jdc.lang.Object
string
 
Constructor Summary
GroupBy()
          Constructs a new GroupBy clause object.
GroupBy(String value)
          Constructs a new GroupBy clause object for the specified column name or names.
 
Method Summary
 GroupBy addName(String column)
          Adds a Column name to the list of Column names.
 GroupBy addName(String table, String column)
          Adds a qualified Table Column name to the list of Column names.
 boolean contains(String table, String column)
          Returns true if the GroupBy list contains the specified Table Column name.
 String getKeyword()
          Returns the GroupBy clause keyword.
 String getValue()
          Returns the GroupBy clause value.
 String toString()
          Returns a String representation of this GroupBy clause.
 
Methods inherited from class com.jdc.rdb.sql.dml.DMLClause
getKeyword
 
Methods inherited from class com.jdc.rdb.sql.SQLClause
contains, setKeyword, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GroupBy

public GroupBy()
Constructs a new GroupBy clause object.


GroupBy

public GroupBy(String value)
Constructs a new GroupBy clause object for the specified column name or names.

Throws:
SQLInvalidException - No GROUP BY column name or names is specified.
Method Detail

addName

public GroupBy addName(String column)
Adds a Column name to the list of Column names. The list of Column names is used to create the GroupBy clause value. Invoke this method as many times as is required to create a list of Column names.

Returns:
This GroupBy clause object.
Throws:
SQLInvalidException - No Column name is specified or the column name is already specified.
See Also:
addName(String, String)

addName

public GroupBy addName(String table,
                       String column)
Adds a qualified Table Column name to the list of Column names. The list of Table Column names is used to create the GroupBy clause value. Invoke this method as many times as is required to create a list of Table Column names.

Returns:
This GroupBy clause object.
Throws:
SQLInvalidException - No Table Column name is specified or the column name is already specified.
See Also:
addName(String)

contains

public boolean contains(String table,
                        String column)
Returns true if the GroupBy list contains the specified Table Column name.

Returns:
True if the list contains the Column name.
False if the list does not contain the Column name.

getKeyword

public String getKeyword()
Returns the GroupBy clause keyword.

Overrides:
getKeyword in class SQLClause
Returns:
The GroupBy clause keyword.

getValue

public String getValue()
Returns the GroupBy clause value.

Overrides:
getValue in class SQLClause
Returns:
The GroupBy clause value.

toString

public String toString()
Returns a String representation of this GroupBy clause.

Specified by:
toString in interface SelectClause
Overrides:
toString in class SQLClause
Returns:
A String representation of this GroupBy clause.

2004.04.29



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