CleanAudit (Example of audit cleanup)

Top  Previous  Next

This is a Wizard created Process template over the Audit file. This process allow you to quickly and automatically move the old records from the Audit file to a separated historical audit file (We will call it AuditBck) while compacts the current audit file. You probably won't need this process for a while, until the system is working at full capacity. It will depend on the movements per day and the period you want to keep your audit information "alive" for your most common queries.

Actually, we noticed that the queries to the audit file become slow when the audit file is holding over a million records. You should analyze which is the working "window" you should keep in your audit file (normally six months seems to be enough to any kind of investigation).

 

Note: There are no template imposed limits regarding the amount of audit records you store in the audit file, but there are limits imposed by the chosen file driver system and server OS. Different file types (like Topspeed, Btrieve, MS-SQL, etc.) have very different record limits, physical size limits and response times. Which is the best for you depend completely in your particular situation.

 

This template works "cutting" the audit file in two. You have to specify a "cut date", and all the records from the beginning to before this date will be moved to the historical file (AuditBck), while the records from this date on to the end of the audit file will be moved to a new file (AuditNew). When the process finishes, the current audit file is removed and the new one is renamed as the current one (AuditNew becomes Audit).

 

Important: Given the way this template works, it is indispensable that

You make a backup of all your data files before you begin.
There is nobody using the system while the process run.
If an error occurs when the process finishes, you must don't do anything else or permit that anyone else use the system until the error is solved.

 

If you want to create this procedure from scratch, you start by use a Wizard to create an empty "Process" over the audit file. Entering the "File Schematic", you must specify the following files:

 

clip0014

Where "AUDIT" is the audit file you want to cleanup, and AUDITBck and AUDITNew have to be defined in the dictionary exactly alike to the audit file. The suffix must be specified in the global extension as shown in "Template usage".

 

Somewhere (locally or globally) you have to declare a field that will receive the "cut date", and you should ask for it in the process window. You also have to populate Clarion's "Pause" control template, so the process ask the date to you before starting the process. The process window may look like this:

 

clip0015

 

Looking at the "Pause" button properties, you have to define the following characteristics:

 

clip0016

 

It is very important that you check the "Start Paused" checkbox, so the process don't start until you press the button.

 

In this example you are going to use an extension to activate the template. Entering by the "Extensions" button, you have to insert a new extension using the "insert" button. The extension template list will show, from which you will pick from the FullRecord extensions the one called "JALExtLimpiarAudit".

 

clip0017

When you select this extension, you have to specify which variable will receive the cut date.

 

clip0018

In this case, you have to select the same date variable that you populated in the process window.

 

Note: Selecting the variable here, allows you to assign the variable in other procedure, using a global variable, or even calculate it. In these cases, you don't need to enter the variable in the process window, and therefore you won't need to populate the "Pause" control template.