Recover (RecuperarAudit) |
Top Previous Next |
You may populate this Control Templates on a Browse over the audit file. It adds all the code needed to recover the full record of the file you are selecting in the Browse. The recovering doesn't need to be from a delete operation.
When you select a proper candidate, and press the recover button, you will see the following message (with the correct file name) if all goes well:
If you select to recover a record that already exists in the original file, you have several options.
(a) First of all, the template issues a warning:
After you press OK, you can go forward. The first question you have to answer is if you want to overwrite the existing record:
If you answer No, you have the option (b): If you answer Yes, you have to confirm that you want to delete the current data in favour of the old one:
If you answer Yes again, you will replace the current record with the audited record. If you answer No, you exit to the Audit browse window.
(b) If you answered No to the "delete the current record" option, you will see this question:
If you answer No, you exit to the Audit browse window. If you answer Yes, the current record is preserved, and the audited record is recovered to the file with a new primary key number (equal to the last available number plus one). Note: This will work if there is a primary key, and if the recover doesn't creates any duplicate key on the secondary keys. If the primary key is a compound key, the field renumbered will be the last field of the key.
***
The correct recover of the record depends that the Primary key be unique. If not, the recovered record will not be in the same order as originally was. Additionally, when you use an autonumber key, if you delete the last added record and then insert another one, this last one takes the number of the previously deleted one, therefore you can only "recover" the erased one deleting the new one or renumbering it. If you need to maintain both and the old one with the original number, a trick to do this is that in your system, you change the key field in the last record added so you make a "hole" in the numbering sequence. The hole should be coincident with the deleted record. Then, you can recover it safely.
If you are not going to record the track of recovered information from the audit file, you should disable the "Record Recover Information" at the local extension. If you use a different "recover record file" than the global one, you may specify it here.
In some SQL systems like MySQL, when you use an autonumber key, the recovered record will always take a new number, unless you recover it using SQL syntax. You may then activate the "Enable SQL for ODBC Autonumber insert" global option in this control to change the insert syntax from Clarion code (ADD...) to SQL code (INSERT INTO...), when the file is SQL (Currently ODBC and Pervasive SQL files are supported).
If your fields are Nullable, you may also check the "Generate empty fields as NULL" global option. This will generate a NULL clause instead of '' or 0 to fill the fields. Keep in mind that if you have any no nullable fields, this option will cause an SQL backend error. |