Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 5 Jahren, 5 Monaten
Letzter Beitrag:
vor 5 Jahren, 5 Monaten
Beteiligte Autoren:
Scott Daughtry, Tor-Bjarne, GuenterP, Ola, Paulo Oliveira, Al

Clarification sought on WD's ability to change data structure "on the fly"

Startbeitrag von Scott Daughtry am 28.09.2012 16:16

I've not yet played with this, so I'm asking the WD experts..

In Clarion, I have a third party template that I can add to my application - it's job is to detect if an application update has changed the structure of one of the application's database files... if a change is detected (e.g. a field is added; an index is added; a field changed from a string to an integer; a field length has been lengthend; etc), a new empty table is created at runtime; the contents of the old table are migrated to the new table; the old table is renamed (to serve as a backup) and the new table is renamed to the old table's name, and a runtime error is stopped due to a data type mismatch. The template controls it all - within a few mouse clicks I can add that functionality and it takes no coding at all to benefit from this feature. Needless to say, this template is worth its weight in gold - it has saved me from having to write a dedicated "data transfer" application that has to be ran on every customer's machine..

I know the WD IDE can / will do this - the $1,000,000 question is this: is a WD application capable of also detecting a change in the table schema when it opens the table and then doing the steps above, or will the WD application halt itself with a critical error and the application terminates?


It depends on what is your db type, if it's for mssql, oracle,... no. If it's for HF classic of HF/CS yes.

check the help for Automatic modification of the data files and you can find a lot information.


von Paulo Oliveira - am 28.09.2012 16:53
Hi Scott,

This problem arises at the time of an app update. In Windev it can be handled without template language programming skills or 3rd party templates. I am no expert, but I handle it so, that when an update is started, the program also downloads and reads an update instruction text file which tells the app what to do, for instance, whether it should run also the data modification process or not.

If this question arises at any other situation, then there probably is something very wrong with the system, and full restore may have to be considered.

See also Guenter's samples, for instance

Best regards

von Ola - am 28.09.2012 17:10
Reading throughthe URL provided above, am I correct in stating that the WD installer is where the data structure check / modification takes place versus inside of the application's *.EXE file?

von Scott Daughtry - am 28.09.2012 21:10
Hello Scott

Windev V12 offered HcreationIfNotFound() as a project option and this works on the fly if a file does not exist. Prior to that you had to do a HCreationIfNotFound("*") in the project init code but it took awhile to run as it searched for the existence of every file in the analysis and caused a time delay every time the app ran.
As part of that code (from an earlier forum message) in the init, you could test for a specific error code

//LCommandLine is string = CommandLine(1)
//If nospace(LCommandLine) = "CREATE"
// //http://f16.parsimony.net/forum28986/messages/22341.htm
// SWITCH ExceptionInfo(errCode)
// CASE 70016: // Run WdModFic
// RunWdModFic()
// END
// END
// HCreationIfNotFound("*")
// // The hcreationifnotfound will trigger error 70016 as it opens all files.

The error code 70016 is still in Windev so you could still use a variant on that code if you wanted to trap the error during code execution and do something about it.

I use a very simple method of keeing my files uptodate. When I issue a patch or update to clients, I also include the project wdd file. My project init code does a search for the wdd file every time the app starts. If the file is in the default app directory then the init code runs WDModfic to change the data base files and then deletes the wdd file. This ensures that it only runs once. Using this method I have never had an issue with changing file structures.

There are some examples in the forum and the Windev help to run WDModfic with a command line but this is what I use

LCurrentDir is string = fCurrentDir //
LWDDFile is string = CompleteDir(LCurrentDir)+"MyApp.wdd"
LModficFile is string = CompleteDir(LCurrentDir)+"WDModfic.exe"
LWDModficLine is string = LModficFile + " -report -nobackup -error /WDD="+LWDDFile+" /DIR="+LCurrentDir+" /US"
IF fFileExist(LWDDFile) AND fFileExist(LModficFile)
IF NOT HClose("*") THEN
Error("Unable to close all the files prior to checking their status."+CR+"Please close all open copies of SCIMS and try again")
END //Hclose
END //FileExist

The update window does a file backup runs wdmodifc, tests that it ran and then deletes the wdd file


von Al - am 29.09.2012 00:35
Scott Daughtry
Reading throughthe URL provided above, am I correct in stating that the WD installer is where the data structure check / modification takes place versus inside of the application's *.EXE file?

Yes Scott, you either rely on the WD installer and will get everything done automatically OR you rely on a different installer (e.g. InnoSetup, InstallShield etc) and include WDMODFIC for restructuring while starting the application. Small applications with a few files aren't any problem while big applications with hundreds of files will start after a long delay - if using HCreationIfNotFound("*"). Imho it's much faster to determine whether WDMODFIC has to be employed at all rather than load WDMODFIC in all cases or even letting a customer unknowingly run into a problem with file structures. Kind regards, Guenter

von GuenterP - am 29.09.2012 11:17

Scott I`f you are in a mixed enviroment like me (Cw and WD access the same SQL-data), and, - if wmodific dont support other SQL DB`s you could use FileManager3 in a small startup-procedure/exe that runs when updating your app. FM3 does a splended job with SQL/ODBC.

The Downside is that you need to import table definitions to WD Analyze each time you create a new table.
And offcourse maintaining both the dct and WD Anayze. :)

I`m (like more clarioneers I guess) moving my app over to wd a project at the time - But FM I just dropped into my app in 199x and forgot all about maintaining filestructures from that point.


von Tor-Bjarne - am 29.09.2012 11:35
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.