The LoBDb.NET recycle bin is a convenient way to restore erroneously deleted records. This mechanism divides the process of deletion in two steps. On the first step a record is deleted from a table as a result of invoking an SQL delete command. On the second step such a record can be restored and or can be permanently deleted from the recycle bin. Let us illustrate it with an example. Suppose that a database contains two tables namely groups and students which are connected by a reference field group_id with the Cascade Delete flag set.


In order to enable editing the tables let’s grant all necessary permissions to the current user.


Then insert a record into the groups table and copy the id value of that row into the clipboard.


Insert two records into the students table that reference the record from the groups table.


After everything is ready issue a delete statement upon the groups table and make sure that all records in the students table were deleted.


All deleted rows can be found in the recycle bin that is opened by clicking Open Recycle Bin on the domain icon. This designer displays the number of deleted rows in each of the tables. Let’s view the deleted rows in the students table by selecting the corresponding table in the designer and clicking the Browse button.


Recycle Bin Explorer allows viewing the fields of deleted records as well as the date and time of deletion and the user that performed that operation. Let’s restore one of the records in the students table by clicking on the Restore Rows button.


If you click the Refresh button in the recycle bin designer at this moment you will find out that the record in the groups table was restored as well because it was referenced by the restored record in the students table.


Let’s make sure that we can read the restored records.


If you do not want to store deleted records you can disable the recycle bin all together. In order to do that unset the Domain has recycle bin enabled checkbox in the properties window of the current domain.


After that the record that was not restored in the students table will become visible again.


Now let’s delete all rows again.


In this case the deletion process cannot be reverted because the deleted records will not end up in the recycle bin.


Last edited Jul 28, 2012 at 4:42 AM by mapase, version 8


No comments yet.