Assume that the scenario is to delete a record from the Employee table based on the Employee ID. A SQL map of the following format –is suitable for the delete operation:
<delete id="EMPLOYEE_DELETE_MYAPP" parameterClass ="java.util.HashMap">
DELETE EMPLOYEE WHERE EMP_ID = #EmployeeId#
</delete>
And the corresponding code would be like -
try {
DatabaseRequest dbRequest = new DatabaseRequest();
dbRequest.setDataAccessMapKey("EMPLOYEE");
dbRequest.setOperation(DatabaseConstants.DELETE)
dbRequest.setOperationExtension("MYAPP");
dbRequest.addFilter(empIdToDelete); //Add the Emp Id to delete as filter
DatabaseResult dbResult = dbRequest.execute(); //Execute the select.
Logger.debug(" # rows deleted = " + dbResult.getNumberOfRowsAffected(); //Get the count of affected rows
} catch (DatabaseException dbException) {
//Handle the exception appropriately.
}
General
Content
Integrations