[solution] Migration from ZEOS to DAC
Posted: Sun 06 Dec 2009 18:58
After hours of converting my application from ZEOS to DAC for MySQL, I have came up with a "few" things to do. Of course you will need a few tools to help you do the job.
Assumption: You use Y and N as ENUM for boolean fields in MySQL. And you don't want to change the database.
If you used ENUM in MySQL to represent Boolean fields in ZEOS then you should know that DAC is different. In DAC you use TinyInt in MySQL to represent Boolean fields where the values 0 for False and 1 for True.
* GExperts at http://www.gexperts.org/: I used Grep Search a lot to find items in the files.
* Beyond Compare at http://www.scootersoftware.com/:
Of course you need to backup your project before starting the migration steps. I take no responsibility for any problems.
In dfm files using (opened as text)
* Replace TZConnection with TMyConnection and User to UserName and delete Protocol and TransactIsolationLevel properties.
* Replace TZQuery with TMyQuery
* Replace TZReadOnlyQuery with TMyQuery and add ReadOnly = True be careful to do this step in the same time or you might loose track of which is which.
* Replace TZTable with TMyTable
* Replace LinkedFields property with DetailFields
* Replace SortedFields property by IndexFieldNames if needed
* Delete WhereMode property from TMyQuery
* Delete ShowRecordTypes property.
* Replace TZUpdateSQL with TMyUpdateSQL component notice that TMyQuery already have the updates properties and you might not need a TMyUpdate any way
* Delete All Params properties from UpdateSQL components since it is not there
* Delete UseSequenceFieldForRefreshSQL from UpdateSQL components
* Replace TBooleanField with TStringField unless you used TinyInt as mentioned later.
* If you have FastReport and you have installed it related components, then replace frxZEOSDatabase with frxMyDacDatabase.
* In DBCheckbox component change the ValueCheck property from True to Y and the ValueUnchecked from False to N.
In Pas code files
* Replace EZSQLException with EMyError and add MyClasses to the uses
* Replace LinkedFields code lines with DetailFields
* Change all ENUM boolean to String, so .AsBoolean becodes .AsString='Y' or .AsString='N'
* Also when you use booleans in the form .Value change it to .Value='Y' or .Value='N'
* Don't forget to add parantheses to those comparisons
* SortedFields don't exist in MyDAC so replace them with IndexFieldNames
* If you used frxMyDacDatabase change HostName property to Server
* Also for frxMyDacDatabase change User property to UserName
* In frxMyDacDatabase remove Protocol
* Replace ParamByName with Params.ParamByName
Units used:
* Replace ZConnection with .
* Replace ZConnection, ZAbstractRODataset, ZAbstractDataset, ZAbstractTable, ZDataset, ZSqlUpdate with MyAccess, MemDS, DBAccess.
In design
* Disable "EnableBoolean" if you use TinyInt values for other non boolean fields (TinyInt is used as boolean field in DAC)
Finally, I was successfull in the migration. Although I didn't like the last point. I will find a way in future to correct this.
PS. If there is any problems or mistakes in this article please tell us. Hope this help others in migrating to DAC for MySQL. This is my second experience.
PS.2: My next project is to convert from MyDAC to SDAC. Which I will post in SDAC forum.
PS.3: Updates are in BOLD
Assumption: You use Y and N as ENUM for boolean fields in MySQL. And you don't want to change the database.
If you used ENUM in MySQL to represent Boolean fields in ZEOS then you should know that DAC is different. In DAC you use TinyInt in MySQL to represent Boolean fields where the values 0 for False and 1 for True.
* GExperts at http://www.gexperts.org/: I used Grep Search a lot to find items in the files.
* Beyond Compare at http://www.scootersoftware.com/:
Of course you need to backup your project before starting the migration steps. I take no responsibility for any problems.
In dfm files using (opened as text)
* Replace TZConnection with TMyConnection and User to UserName and delete Protocol and TransactIsolationLevel properties.
* Replace TZQuery with TMyQuery
* Replace TZReadOnlyQuery with TMyQuery and add ReadOnly = True be careful to do this step in the same time or you might loose track of which is which.
* Replace TZTable with TMyTable
* Replace LinkedFields property with DetailFields
* Replace SortedFields property by IndexFieldNames if needed
* Delete WhereMode property from TMyQuery
* Delete ShowRecordTypes property.
* Replace TZUpdateSQL with TMyUpdateSQL component notice that TMyQuery already have the updates properties and you might not need a TMyUpdate any way
* Delete All Params properties from UpdateSQL components since it is not there
* Delete UseSequenceFieldForRefreshSQL from UpdateSQL components
* Replace TBooleanField with TStringField unless you used TinyInt as mentioned later.
* If you have FastReport and you have installed it related components, then replace frxZEOSDatabase with frxMyDacDatabase.
* In DBCheckbox component change the ValueCheck property from True to Y and the ValueUnchecked from False to N.
In Pas code files
* Replace EZSQLException with EMyError and add MyClasses to the uses
* Replace LinkedFields code lines with DetailFields
* Change all ENUM boolean to String, so .AsBoolean becodes .AsString='Y' or .AsString='N'
* Also when you use booleans in the form .Value change it to .Value='Y' or .Value='N'
* Don't forget to add parantheses to those comparisons
* SortedFields don't exist in MyDAC so replace them with IndexFieldNames
* If you used frxMyDacDatabase change HostName property to Server
* Also for frxMyDacDatabase change User property to UserName
* In frxMyDacDatabase remove Protocol
* Replace ParamByName with Params.ParamByName
Units used:
* Replace ZConnection with .
* Replace ZConnection, ZAbstractRODataset, ZAbstractDataset, ZAbstractTable, ZDataset, ZSqlUpdate with MyAccess, MemDS, DBAccess.
In design
* Disable "EnableBoolean" if you use TinyInt values for other non boolean fields (TinyInt is used as boolean field in DAC)
Finally, I was successfull in the migration. Although I didn't like the last point. I will find a way in future to correct this.
PS. If there is any problems or mistakes in this article please tell us. Hope this help others in migrating to DAC for MySQL. This is my second experience.
PS.2: My next project is to convert from MyDAC to SDAC. Which I will post in SDAC forum.
PS.3: Updates are in BOLD