java.lang.Object
javatools.db.DbDeleter
- Direct Known Subclasses:
- DbReferencedDeleter
- public class DbDeleter
- extends java.lang.Object
A class used to delete records from SQL tables. The constructor is not
public. To obtain a DbDeleter call DbTable.deleter(); Example: To delete all
the people who are (younger than 18 or older than 80) and whose name is
"Fred"...
DbDatabase db = ...;
DbTable people = db.getTable("PEOPLE");
DbDeleter deleter = people.deleter();
deleter.setWhere(people.getColumn("AGE").lessThan(new Integer(18)).or(
people.getColumn("AGE").greaterThan(new Integer(80))).and(
people.getColumn("NAME").equal("FRED"));
int numberOfPeopleDeleted = deleter.execute();
This is equivilent to...
DELETE FROM PEOPLE WHERE (AGE < 18 OR AGE > 80 ) AND NAME='Fred'
Note the use of equal(), NOT equals().
- Version:
- 0.2.0
|
Field Summary |
(package private) DbAbstractTable |
table
The table for this operation. |
(package private) DbExpr |
where
The where clause to select rows for deletion. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
table
DbAbstractTable table
- The table for this operation.
where
DbExpr where
- The where clause to select rows for deletion.
DbDeleter
DbDeleter(DbAbstractTable table)
- Builds a new DbDeleter object.
setWhere
public void setWhere(DbExpr where)
- Set the where condition for this delete operation.
execute
public int execute(DbConnection dbcon)
throws DbException
- Execute this delete command on a specific connection.
execute
public int execute()
throws DbException
- Execute this command on the default connection.
getQueryString
java.lang.String getQueryString()
throws DbException
- Returns the query string related to this deleter.