For this example, assume that an employee has identified a damaged container during manual inspection, and you want to model a rule to delete that container’s record from the database so that it will not be assigned to a FlightPlan.

Create a Rulesheet named DeleteRecord.ers that uses Cargo.ecore as its Vocabulary. Model a rule as shown here (remember to create a rule statement and link it to the rule):

media/image61.png

Note how the .remove operator is used in the action-only rule. No parameters are required in the .remove operator. The rule is non-conditional.

If you have followed all the steps in tutorial, the dbo.Cargo table should now have four records:

media/image62.png

Assuming that 625C is the damaged container, let’s test the Rulesheet by supplying this manifestNumber in the Ruletest’s input.

Create a Ruletest named DeleteRecord.ert that uses DeleteRecord.ers as its test subject. Configure the Ruletest to perform write operations on the database by selecting Ruletest > Testsheet > Database Access > Read/Update.

Define the record 625C as the input and run the test. You should be able to see the Warning message that is linked to the rule:

media/image63.png

Let’s verify that this record has been deleted from the database. In SQL Server Management Studio, right-click dbo.Cargo and select Select Top 1000 Rows. You should see the following result:

media/image64.png

The record 625C is gone. There are only three records in this table now.