Class RWDBDeleter is used to delete rows from database tables. A deleter is obtained by requesting one from a database table, and it may be supplied with an RWDBCriterion to express a restriction on the rows to be deleted. You can express a restriction through a where() method, just as with RWDBSelector and RWDBUpdater. The structure should be familiar by now:
int videoID = 1234; RWDBTable purchases = myDbase.table("purchase"); RWDBDeleter deleter = purchases.deleter(); deleter.where(purchases["videoID"] == videoID); //1 deleter.execute(myConnection); //2
This example is equivalent to an SQL statement of this type:
DELETE FROM purchase WHERE videoID = 1234
It is executed on //2, deleting the rows in the purchase table whose videoID column contains the value 1234. As with RWDBUpdater, the where() call on //2 is important. Omitting it would have caused all rows in the purchase table to be deleted. Executing a deleter without calling the where() method, which assigns a criterion, causes all rows within the table to be deleted.
NOTE: Executing a deleter without first assigning a criterion causes all rows of the table to be deleted.
As with an updater, once a criterion has been assigned to a deleter using the where() method, that criterion is retained. The where() method can be called at anytime to set a new criterion, or it can be called with an empty criterion to clear the criterion. The considerations regarding results and connections for RWDBInserter and RWDBUpdater apply equally to RWDBDeleter.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.