2004.04.29


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

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

public class OrderBy
extends DMLClause
implements SelectClause

OrderBy represents a Select SQL statement ORDER BY clause. The ORDER BY clause specifies specifies an ordering of the rows of the result Table. If a single sort specification (one sort-key with associated direction) is identified, the rows are ordered by the values of that sort specification. If more than one sort specification is identified, the rows are ordered by the values of the first identified sort specification, then by the values of the second identified sort specification, and so on.

Ordering is performed in accordance with comparison rules. The null value is higher than all other values. If the ORDER BY clause does not completely order the rows, rows with duplicate values of all identified columns are displayed in an arbitrary order.

Valid column sort orders are:

Refer to the Order class for a list of valid sort orders.
Reference:
IBM® DB2 Universal Database™ SQL Reference Volume 1 Version 8, Pages 576 thru 579.
Note:
An error will occur if the SELECT statement specifies DISTINCT in the select clause.

Version:
2.0
Author:
Jay Damon
See Also:
Select, Order, 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
OrderBy()
          Constructs a new OrderBy clause object.
OrderBy(String value)
          Constructs a new OrderBy clause object for the specified column name or names.
 
Method Summary
 OrderBy addName(String column)
          Adds a Column name to the list of Column names.
 OrderBy addName(String table, String column)
          Adds a Table Column name to the list of Column names.
 OrderBy addName(String table, String column, String order)
          Adds a Table Column name and sort order to the list of Column names.
 boolean contains(String table, String column)
          Returns true if the OrderBy list contains the specified Table Column name.
 String getKeyword()
          Returns the OrderBy clause keyword.
 String getValue()
          Returns the OrderBy clause value.
 String toString()
          Returns a String representation of this OrderBy 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

OrderBy

public OrderBy()
Constructs a new OrderBy clause object.


OrderBy

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

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

addName

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

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

addName

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

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

addName

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

Returns:
This OrderBy clause object.
Throws:
SQLInvalidException - No Table Column name is specified, the column name is already specified, or the sort order is not valid.
See Also:
addName(String)

contains

public boolean contains(String table,
                        String column)
Returns true if the OrderBy 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 OrderBy clause keyword.

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

getValue

public String getValue()
Returns the OrderBy clause value.

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

toString

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

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

2004.04.29



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