javatools.db
Class DbDeleter
java.lang.Object
|
+--javatools.db.DbDeleter
- 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().
Method Summary |
int |
execute()
Execute this command on the default connection. |
int |
execute(DbConnection dbcon)
Execute this delete command on a specific connection. |
(package private) java.lang.String |
getQueryString()
|
void |
setWhere(DbExpr where)
Set the where condition for this delete operation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
table
DbTable table
where
DbExpr where
DbDeleter
DbDeleter(DbTable table)
setWhere
public void setWhere(DbExpr where)
- Set the where condition for this delete operation.
- Parameters:
where
- The new where value
execute
public int execute(DbConnection dbcon)
throws DbException
- Execute this delete command on a specific connection.
- Parameters:
dbcon
- Description of Parameter
- Returns:
- The number of record affected.
- Throws:
DbException
- Description of Exception
execute
public int execute()
throws DbException
- Execute this command on the default connection.
- Returns:
- The number of record affected.
- Throws:
DbException
- Description of Exception
getQueryString
java.lang.String getQueryString()
throws DbException
DbException