2004.04.29


com.jdc.rdb.sql.dml.delete
Class Delete

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

public class Delete
extends DML

Delete represents a Data Manipulation Language Delete SQL statement. The Delete statement deletes one or more rows from a database Table or View. Deleting a row from a View deletes the row from the Table on which the View is based.

There are two (2) forms of this statement:

Currently, only Delete by a search condition is supported.
Invocation:
This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared.
Authorization:
To execute this statement, the privileges held by the authorization ID of the statement must include at least one of the following (for IBM® DB2 Universal Database™):

Additionally, to execute a searched Delete statement, the privileges held by the authorization ID of the statement must also include at least one of the following for each table or view referenced by a subquery (for IBM® DB2 Universal Database™):
Example:
        Delete delete = new Delete(table);

        delete.setWhere(column 1 ,  123 );  
        delete.setWhere(column 2 , "Key");  
        . . .

        DeleteStatus status = delete.execute();
 
        if (status.isSuccessful())
        {
            // Delete success
        }
        else
        {
            // Delete failed!
        }
Reference:
IBM® DB2 Universal Database™ SQL Reference Volume 2 Version 8, Pages 497 thru 503.
Note:
Delete from a View is not currently supported.

Version:
2.0
Author:
Jay Damon
See Also:
From, Correlation, Where, With, Serialized Form

Field Summary
static String COMMAND
          The Delete 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
Delete()
          Constructs a new Delete statement object.
Delete(String statement)
          Constructs a new Delete statement object for the specified Delete statement.
Delete(Table table)
          Constructs a new Delete statement object for the specified Database Table.
 
Method Summary
 DeleteStatus execute()
          Executes the Delete statement and returns a DeleteStatus object.
 From getFrom()
          Returns the From clause for this Delete statement.
 Where getWhere()
          Returns the Where clause for this Delete statement.
protected  boolean isValid()
          Returns true if the Delete statement is valid.
 Delete set(DeleteClause clause)
          Sets a DeleteClause for this Delete statement.
 Delete setWhere(Column column, int value)
          Sets a search condition for the specified table Column and int value.
 Delete setWhere(Column column, Object value)
          Sets a search condition for the specified table Column and Object value.
 String toString()
          Returns a String representation of this Delete statement.
 
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, execute, getClause, getCommand, getStatement, setCommand, setConnection, setStatement
 
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 Delete statement command keyword.

See Also:
Constant Field Values
Constructor Detail

Delete

public Delete()
Constructs a new Delete statement object.


Delete

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

Throws:
SQLInvalidException - No table definition is specified.

Delete

public Delete(String statement)
Constructs a new Delete statement object for the specified Delete statement.

Throws:
SQLInvalidException - No DELETE statement is specified.
Method Detail

execute

public DeleteStatus execute()
Executes the Delete statement and returns a DeleteStatus object.

Returns:
The Delete statement status.

getFrom

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

Returns:
The Delete statement From clause.

getWhere

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

Returns:
The Delete statement Where clause.

isValid

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

Overrides:
isValid in class SQL
Returns:
This method always returns true.

set

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

Returns:
This Delete statement object.
Throws:
SQLInvalidException - No DELETE statement clause is specified.

setWhere

public Delete 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 Delete statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

setWhere

public Delete 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 Delete statement object.
Throws:
SQLInvalidException - No column is specified or an invalid table column is specified.

toString

public String toString()
Returns a String representation of this Delete statement.

Specified by:
toString in interface Statement
Overrides:
toString in class SQL
Returns:
A String representation of this Delete statement.

2004.04.29



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