Version 2.1.3.0 (Released October 2019)

If you previously only have used DUF 1.0, it is imporant that you first read What's New in Version 2.0.0.00


It is crusial that both the DataAccess database driver and the database client version are of the right version(s) for your program to run successfully. A new message and a new event was introduced to automatically check both of these versions at program start up. The new event was created for the cDbUpdateHandler class (the outer DUF object). The event was named OnCreate and the function name is Function UtilLowestAllowedMSSQLDRV_And_ClientVersion


Note: It is important to understand that you should never put any update code inside the new OnCreate event, as it will always be executed when the program is started.


Your code could look like this;


Object oDbUpdateHandler is an cDbUpdateHandler
    Set piDbVersionFileNumber to 117

    Set piDbVersionFieldNumber to 1

    Set pbAutoCreateDbVersionTable to True  

    Set psCollation to "Latin1_General_CS_AS"

    Set pbEnableCancelButton to True

   

    Procedure OnCreate

        String sVersionInfo  

        Get UtilLowestAllowedMSSQLDRV_And_ClientVersion "6.3.0.13" 10 True True to sVersionInfo

    End_Procedure


End_Object


A series of new functions were introduced to make the transformation from the DataFlex Embedded database (*.dat tables) to SQL. To make the transition smoother it is important that all *.dat tables first are repaired and reindexed. It is also important that *no* nul or zero date values exist in the *.dat tables as SQL doesn't like that at all and will break the copying of values over to SQL.


To make it really easy a series of new "initializing" functions were combined into one; Function UtilPrepareDataFolderForSQLConversion.


Object oDbUpdateHandler is an cDbUpdateHandler
.

.

.

    Object oDbUpateVersion1.1 is a cDbUpdateVersion

        Set pnVersionNumber to 1.1

        Procedure OnUpdate

            Boolean bOK

            Get UtilPrepareDataFolderForSQLConversion True True True True True to bOK

        End_Procedure

    End_Object


End_Object


The UtilPrepareDataFolderForSQLConversion function is a combination of five other functions;


1.UtilMoveMiscFilesToBackupFolder that moves a number of files from the Data folder to a sub backup folder.

2.UtilTableFixALLBogusFilelistEntries, removes any Filelist.cfg entries that doesn't have a corresponding .Dat or .Int file in the Data folder.

3.UtilTableConvertALLTablesFrom23Format converts any *.Dat table from 2.3 format to 3.0/4.0 that more modern DataFlex versions are using. This is essential for DataFlex to be able to repair & reindex tables.

4.UtilTableRepairAndReindexALL - Repairs (and creates *.bad files) for all .Dat tables in Filelist.cfg and then reindex them.

5.UtilTablesFixAllDateBogusValues - Checks all Filelist.cfg tables and all fields for Date values, and changes all date values lower than the predefined constant CS_DUFLowestAllowedDateValue (= "01/01/1753"). That constant can be changed if really needed.


As explained in "What's New in Version 2.0.0.00" you should use the new tool DUF Code Generator to auto-generate an "image" of your current/latest database version. Use the tool to generate a file name like e.g. "DUF_MultipleTables1_5.pkg" and Use it inside the cDbUpdateHandler object.


The main message that is used by the auto-generated code logic is ApiTableUpdate. New logic for the ApiTableUpdate function works like this. If a "From" table (from e.g. DUF_MultiTables1_5.pkg) is an SQL database driver and the "To" database table is a *.dat table (on the machine it is running on), the logic will first check if the table already exists on the SQL back-end. And if so it will attach to the existing SQL table rather than trying to convert the .Dat table to SQL.


If the "To" table is a .Dat table and the "From" table is in the SQL, the .Dat table will be converted to SQL.