Index Dictionary for Alpha5
Alpha5 DBF database structures are known to loose indexes from time to time. The reasons this happens is not always clear but it does cause issues for Alpha5 applications that make use of and expect certain index files to be present.
This package provides a Index dictionary for your application. It allows the end user to rebuild missing indexes and allows your application to intelligently deal with index that may be missing, giving the end user the opportunity to rebuild them without your intervention.
This package also assist the developer in keeping track of indexes required and the frequency of their use. The package will even scan your code to verify index usage.
Installation
------------
The ZIP consists of 6 files idx.txt file contains 5 functions and 1 class.
The functions are listed below, the class provides a progress indicator used when reindexing.
Right Click on empty area of the Code Tab to deselect any selected script and select Import from the pop up menu.
Import the *.txt file.
Copy the IDX.DBF file to the folder used by your database.
From the Table Tab of the AlphaFive Control Panel Right click in an empty area and select Add Table/Set from the pop up menu.
Select IDX.DBF from the Table/Set Names listed and select Add > this will build the support files required so the forms can be added for the table.
The two forms are provided IDX and IDXqry they are located in the files IDX_form.a5pkg and IDXqry_Form.a5pkg respectively.
Right Click on empty area of the Form Tab and selecting import from the pop up menu.
When the first form is imported you will need to Select a table to unpack it to.
Select the IDX table you just added to the database.
You will not need to select the Table when you import the second form.
Now open the IDX form to access the Index Dictionary. This form is intended for use by the Alpha Five devolper, I would not recommend you give the end user access to this form.
The first action is to populate the dictionary using the <Build Dictionary> button.
After initially building the dictionary use the <Update Dictionary> so you do not remove any index's from the dictionary that may have gone missing since the last rebuild.
FUNCTIONS
---------
IDX() is a single function that provides all the code run from the buttons on the IDX form.
IDXPUT() is a function that should be used when selecting a index in your code, it works with the Index Dictionary (IDX.DBF) to accomplish the following;
- Selects the index using full name specified unlike to equivalent A5 methods for index selection
- If the index is missing, build a temporary sort order if possible and return pointer to it
- Flag tables that require index rebuild if a index is missing, these tables are pre-selected when the IDXREBUILD() function is used.
- Gather statistics on the Index's usage.
See the comments in the IDXPUT() function for details on it's use.
IDXREBUILD() will rebuild indexes it can be called from your application and used by the end user. See the comments at the start of this function for details on it's use.
IDXSET() is a function used to set the primary index for a table or browse. It in turn uses IDXPUT() and will display any error messages.
US2IDRangeChk() is a sample of a function used to check a value instead using a field rule.
A5 Index Issues
---------------
The introduction indicates that Alpha5 can loose indexes all on it's own. One cause of this is; indexing expressions that cannot be evaluated. When Alpha5 saves a change to a record it next has to update indexs for that table. If an index expression cannot be evaluated Alpha5 is unable to back out of the save operation (it doesn't have the ability to do Atomic transactions) and the index is no longer valid so it is dropped. The index MAY reappear on subsequent opening of the table if the expression is once again valid.
This is easily demonstrated by defining a global variable with a value and using it in a indexing expression. Update some record that use the index. Next delete the Global variable and update a record in the table and you will see the index be deleted.
Alpha Five will build many index's on it's own. Some of these are easily recognized by thier names, these are not added to the Index Dictionary. Look at the first of the IDX() function to see a list on Indexs that are excluded from the Index Dictionary.
Other Index's Built by Alpha Five are required for linking tables in sets, these will have unique names based on the fields involved these will be included in the index dictionary.
Alpha Five will at times build indexs that contain comma's in the Index Name. The Alpha Five routines used by this package to build the index's do not support the use of commas in the index names.
Before building an index for it's own internal use Alpha5 will see if an index with the correct defination exist. If one does it will be used. So if a index that would contain commas in the name is built under a different name the issue of index names with commas is avoided.
Alpha5 will build indexes for use by field rules, for example unique checks. These indexes will always be built with name selected internally by Alpha5. This can be seen by creating a unqiue check field rule. Going to the index definition for this table and deleting all indexes. Close index editor and then reopen it. The Index required by the Alpha5 field rule will have been recreated.
Because the IDXrebuild() function does much the same thing, it deletes all indexes for a table and then rebuilds them. Any index used in field rules will always have the name generated by Alpha5 regardless of the name placed in the IDX table. This is because Alph5 builds the index before the IDXrebuild() function has a chance to.
A solution to this problem is to move the unique check to Field Event in the field rules;
Field Event -> Record Events -> CanSaveRecord
Code:
IF .NOT. US2idrangechk(a_users_idrange->CODE,a_users_idrange->low,a_users_idrange->high)
cancel()
end if
It is best that the event code calls a function so the index used can be determined by the IDX scan function.
A sample Function is provide in the idx*.txt file with the name US2IDRangeChk()
Alpha5 DBF database structures are known to loose indexes from time to time. The reasons this happens is not always clear but it does cause issues for Alpha5 applications that make use of and expect certain index files to be present.
This package provides a Index dictionary for your application. It allows the end user to rebuild missing indexes and allows your application to intelligently deal with index that may be missing, giving the end user the opportunity to rebuild them without your intervention.
This package also assist the developer in keeping track of indexes required and the frequency of their use. The package will even scan your code to verify index usage.
Installation
------------
The ZIP consists of 6 files idx.txt file contains 5 functions and 1 class.
The functions are listed below, the class provides a progress indicator used when reindexing.
Right Click on empty area of the Code Tab to deselect any selected script and select Import from the pop up menu.
Import the *.txt file.
Copy the IDX.DBF file to the folder used by your database.
From the Table Tab of the AlphaFive Control Panel Right click in an empty area and select Add Table/Set from the pop up menu.
Select IDX.DBF from the Table/Set Names listed and select Add > this will build the support files required so the forms can be added for the table.
The two forms are provided IDX and IDXqry they are located in the files IDX_form.a5pkg and IDXqry_Form.a5pkg respectively.
Right Click on empty area of the Form Tab and selecting import from the pop up menu.
When the first form is imported you will need to Select a table to unpack it to.
Select the IDX table you just added to the database.
You will not need to select the Table when you import the second form.
Now open the IDX form to access the Index Dictionary. This form is intended for use by the Alpha Five devolper, I would not recommend you give the end user access to this form.
The first action is to populate the dictionary using the <Build Dictionary> button.
After initially building the dictionary use the <Update Dictionary> so you do not remove any index's from the dictionary that may have gone missing since the last rebuild.
FUNCTIONS
---------
IDX() is a single function that provides all the code run from the buttons on the IDX form.
IDXPUT() is a function that should be used when selecting a index in your code, it works with the Index Dictionary (IDX.DBF) to accomplish the following;
- Selects the index using full name specified unlike to equivalent A5 methods for index selection
- If the index is missing, build a temporary sort order if possible and return pointer to it
- Flag tables that require index rebuild if a index is missing, these tables are pre-selected when the IDXREBUILD() function is used.
- Gather statistics on the Index's usage.
See the comments in the IDXPUT() function for details on it's use.
IDXREBUILD() will rebuild indexes it can be called from your application and used by the end user. See the comments at the start of this function for details on it's use.
IDXSET() is a function used to set the primary index for a table or browse. It in turn uses IDXPUT() and will display any error messages.
US2IDRangeChk() is a sample of a function used to check a value instead using a field rule.
A5 Index Issues
---------------
The introduction indicates that Alpha5 can loose indexes all on it's own. One cause of this is; indexing expressions that cannot be evaluated. When Alpha5 saves a change to a record it next has to update indexs for that table. If an index expression cannot be evaluated Alpha5 is unable to back out of the save operation (it doesn't have the ability to do Atomic transactions) and the index is no longer valid so it is dropped. The index MAY reappear on subsequent opening of the table if the expression is once again valid.
This is easily demonstrated by defining a global variable with a value and using it in a indexing expression. Update some record that use the index. Next delete the Global variable and update a record in the table and you will see the index be deleted.
Alpha Five will build many index's on it's own. Some of these are easily recognized by thier names, these are not added to the Index Dictionary. Look at the first of the IDX() function to see a list on Indexs that are excluded from the Index Dictionary.
Other Index's Built by Alpha Five are required for linking tables in sets, these will have unique names based on the fields involved these will be included in the index dictionary.
Alpha Five will at times build indexs that contain comma's in the Index Name. The Alpha Five routines used by this package to build the index's do not support the use of commas in the index names.
Before building an index for it's own internal use Alpha5 will see if an index with the correct defination exist. If one does it will be used. So if a index that would contain commas in the name is built under a different name the issue of index names with commas is avoided.
Alpha5 will build indexes for use by field rules, for example unique checks. These indexes will always be built with name selected internally by Alpha5. This can be seen by creating a unqiue check field rule. Going to the index definition for this table and deleting all indexes. Close index editor and then reopen it. The Index required by the Alpha5 field rule will have been recreated.
Because the IDXrebuild() function does much the same thing, it deletes all indexes for a table and then rebuilds them. Any index used in field rules will always have the name generated by Alpha5 regardless of the name placed in the IDX table. This is because Alph5 builds the index before the IDXrebuild() function has a chance to.
A solution to this problem is to move the unique check to Field Event in the field rules;
Field Event -> Record Events -> CanSaveRecord
Code:
IF .NOT. US2idrangechk(a_users_idrange->CODE,a_users_idrange->low,a_users_idrange->high)
cancel()
end if
It is best that the event code calls a function so the index used can be determined by the IDX scan function.
A sample Function is provide in the idx*.txt file with the name US2IDRangeChk()
Comment