edu.jhu.tmaj.database.sql
Class DeleteSQL
java.lang.Object
edu.jhu.tmaj.database.sql.ModifySQL
edu.jhu.tmaj.database.sql.DeleteSQL
- All Implemented Interfaces:
- SQL
public final class DeleteSQL
- extends ModifySQL
- implements SQL
Represents a DELETE SQL statement.
Example--
To create SQL statement:
DELETE FROM Specimens WHERE Hospital = 'JHH' AND SurgPathNumber = 'S41-84313'
DeleteSQL deleteSQL=DeleteSQL.getInstance("Specimens");
deleteSQL.addCondition("Hospital","JHH");
deleteSQL.addCondition("SurgPathNumber","S41-84313");
In most TMAJ deletes, you only use one columname as the condition, for example:
DELETE FROM Users WHERE UserID = 53
You can create this statement in just one line of code using the shortcut:
DeleteSQL deleteSQL2=DeleteSQL.getInstance("Users","UserID",53);
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
getInstance
public static DeleteSQL getInstance(java.lang.String tableName)
- Returns a instance of a DeleteSQL. NOTE: By default, executing this statement will delete
every record in a table, so make sure you remember to add the conditions which will limit
which rows are deleted.
getInstance
public static DeleteSQL getInstance(java.lang.String tableName,
java.lang.String columnName,
long value)
addCondition
public void addCondition(java.lang.String columnName,
long value)
- Adds a condition onto which record(s) will be deleted. For example addCondition("OfficeID",
5) will only delete records whose OfficeID field is equal to 5.
getWhereSQLValues
public SQLValues getWhereSQLValues()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object