Delete Actions

Types of DeleteActions

None

A None deletion action will delete selected row in the table but nothing occurs to the table that relate to this table.

Cascade

A cascading deletion action will delete all records in the related table, where the foreign key is equivalent to the primary key of the current table. That is, deleting the parent record will also delete the child record(s) in the related table.
This cascading will take place whether the deletion is performed in code or directly by a user through the user interface.

Restricted

A restricting delete action will raise an error message if the user tries to delete a record, where records exist in the related table where the foreign key is equivalent to the primary key of the current table.
This error will only appear if the deletion is performed through the user interface. A deletion from X++ code will be allowed to proceed and will not be cascaded to the related table. In this case the programmer should call .validateDelete() themselves prior to the call to .delete()

Cascade+Restricted

Cascade+Restricted comes into exist only when we are dealing with more than two tables.

The delete action performs an restricted, if the record of the table will be deleted directly and performs an cascade, if the record of the table will be deleted through a cascade delete action of a other table.

E.g.: tableA (Customer) (a cascade deleteaction to tableB) tableB (SalesOrder) (a cascade+restricted deleteaction to tableC) tableC (SalesLine)
When a record of tableB will be deleted, the restricted part of the deleteaction will be performed. The record of tableB can only be deleted, if no record in tableC exist for the record in tableB. (The SalesOrder can only be deleted, if no SalesLine exist for the SalesOrder).
A record in tableA will be deleted, so the cascade deleteaction to tableB will be performed. In this case, the cascade part of the deleteaction to tableC will be performed. (When a Customer will be deleted, the SalesOrders and SalesLines will also be deleted)

So, the performing action of a cascade+restriced deleteaction depends on the kind of deletion of the record. (direct:restricted, cascading:cascade)

If a cascade+restriced deleteaction is performed on a table for the related table it acts as a restriced deleteaction.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s