[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Disaster Recovery
One of FlexFile's advantages is that it is very robust against common
disaster situations such as power loss. Your DBV file may get damaged
during such a calamity, however, the damage done is local to the write
that was in progress when the interuption occurred. That is, there is
no immediate ripple effect from a damaged section of a DBV to non
damaged sections.
On the other hand, if your file gets damaged and you continue to use it,
you CAN cause more damage. Therefore, you should prepare your code for
such an occurance (you can always rely on backups, but sometimes clients
simply fail to do their job of backing up regularly).
If V_REPLACE() or V_DELETE() return a logical value (as opposed to a
character value) and/or V_ERROR() reports a 6200, 6500, 6700 or 9000
class of error, the DBV file may be corrupt. (Syntax errors in calling
FlexFile functions can also cause these errors so check your syntax
first.)
When you are certain that your syntax is not causing the problem, you
should rebuild the DBV file. Rebuilding is a simple process and is
outlined by the following code. The code is based on a DBF file called
"dbf_file.dbf" which has a six byte character field (a FlexFile
pointer-field) called <vlf>. We then open the existing DBV and create a
new DBV into which to copy the old data. Finally, we erase the old DBV
and rename the new one back to the old.
Before any code such as this is implemented you should back up the files
involved.
// Open the controlling DBF and the DBV (with an alias of "OLD")
USE dbf_file
V_USE( "dbv_file", "old" )
// Open a new DBV to recieve the copyable data (with an alias of "NEW").
V_SELECT(0)
V_USE( "tempdbv", "new" )
DO WHILE !EOF()
IF V_TYPE( dbf_file->vlf, "old" ) == 'U'
QOUT( "This record is damaged." )
WAIT
LOOP
ENDIF
// If the type is Char, Num, Log, Date, or FlexFile array
IF V_TYPE( dbf_file->vlf, "old" ) $ "CNLDF"
// Get the value from the DBV.
var = V_RETRIEVE( dbf_file->vlf, "old" )
// Write the value to the new DBV.
dbf_file->vlf := V_REPLACE( var, space(6), "new" )
// else the type must be an array.
ELSE
// Get the array from the DBV
var = V_ARETRIEVE( dbf_file->vlf, "old" )
// Write the array to the new DBV
dbf_file->vlf := V_AREPLACE( var, space(6), "new" )
ENDIF
SKIP
ENDDO
FERASE( "dbv_file.dbv" )
FRENAME( "tempdbv.dbv", "dbv_file.dbv" )
The other form of "disaster" that is fairly common is to loose a DBF
file that has pointer-fields into a DBV. This is a very serious
situation because there is nothing in the DBV which points back into the
DBF. However, there is a new function V_WALK_DBV() that allows the
programmer to step from field to field through the DBV file. The steps
go from physical field to physical field and so the logical order of the
file is lost. However, in extreme situations this function may be
helpful. See V_WALK_DBV() for more information.
See Also:
V_WALK_DBV()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson