Migrating from Interbase Express (IBExpress) to FireDAC


In my last blog I explained how to migrate from BDE to FireDAC. Here I will show you how to migrate a client-server application using Interbase Express data access components, such as TIBDatabaseTIBTransaction, TIBQueryTTable, to the FireDAC. It shows the basic principles of replacing the common components, properties and code, preserving the developers working time and avoiding the common migration pitfalls.

So lets start in steps.

1. Units Changed
We need to replace used IBExpress units to FireDAC units.
Find 
IBDatabase, IBCustomDataSet, IBTable, IBStoredProc, IBQuery, IBUpdateSQL, IBSQL, IBDatabaseInfo, IBEvents, IBScript
Replace
          FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Phys, FireDAC.Stan.Pool,
FireDAC.Stan.Async, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
FireDAC.DApt, FireDAC.Comp.Client, FireDAC.Comp.DataSet

2. IBExpress components classes compatible with FireDAC
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
TIBDatabase
TFDConnection
TIBTransaction
TFDTransaction
TIBTable
TFDTable
TIBQuery
TFDQuery
TIBStoredProc
TFDStoredproc
TIBSQL
TFDCommand
TIBUpdateSQL
TFDUpdateSQL
TIBDatabaseInfo
TFDIBInfo
TIBScript
TFDScript

3. Other Types classes changed
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
TParams
TFDParams
TBlobStream
TFDBlobStream
TBDEDataSet
TFDRDBMSDataSet

4. TIBDatabase -> TFDConnection Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
DatabaseName
ConnectionName
DefaultTransaction
Transaction
ServerType
Not Supported so remove.
TraceFlags
Not Supported so remove.

Note* - OnLogin Event
TIBDatabase.OnLogin event is different than TFDConnection.OnLogin. So we should remove Tdatabase event and re-write TFDConnection Event.

5. TIBTransaction -> TFDTransaction Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
DefaultDatabase
Connection
Active
Not Supported so remove.
AllowAutoStart
Options.AutoStart
AutoStopAction
Not Supported so remove.
DefaultAction
Not Supported so remove.
Params
Options.Params
  
6. TIBTable -> TFDTable Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
BufferChunks
FormatOptions.InLineDataSize
Database
Connection
Readonly
UpdateOptions.Readonly
StoreDefs
Not Supported so remove.
TableTypes
Not Supported so remove.
Unidirectional
FetchOptions.Unidirectional

7. TIBQuery -> TFDQuery Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
BufferChunks
FormatOptions.InLineDataSize
Database
Connection
Datasource
MasterSource

Note. Please check MasterFields
GeneratorName
UpdateOptions.GeneratorField

Datasource
MasterSource

Note. Please check MasterFields

ParamCheck
ResourceOptions.Paramcreate
Requestlive
UpdateOptions.Requestlive
Unidirectional
UpdateOptions.Unidirectional

8. TIBStoredProc -> TFDStoredProc        Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
Database
Connection

9. TIBSQL -> TFDCommand  Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
Database
Connection
ParamCheck
ResourceOptions.Paramcreate
SQL
CommandText

10. TIBUpdateSQL -> TFDUpdateSQL      Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC

Connection
RefreshSQL
FetchSQL

10. TIBDatabaseInfo -> TFDInfo    Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
Database
DriverLink

11. TIBScript -> TFDScript    Properties
Search IBEXPRESS classes and replace with FireDAC classes

 IBEXPRESS
 FireDAC
Database
Connection
Dataset
Not Supported so remove
Scripts
SQLScripts
Terminator
ScriptOptions.CommandSeparator

12. Sorting
FireDAC components like TFDQuery, TFDTable does not have Sort property. So we have to use IndexFieldNames property for sorting. So where ever we have used Sort for sorting in our project we need to replace with IndexFieldNames like follow.
ADQuery1.IndexFieldNames := 'ORDERID';
or
ADQuery1.IndexFieldNames := 'OrderDate:D;Price'; //D for descending//

13. TBookMark Changes for Dataset components
When we save a bookmark for future use we must use pointer for
var
BookMark : Pointer;
CDS : TClientDataset
……
// Required so your assignment doesn't attempt to free a non-existent bookmark //
 Bookmark := nil;
 TBookmark(Bookmark) := CDS.GetBookmark;

14. Data Property
If we use TFDQuery and ClientDataset together then Data property is mostly used to assign saved data to any other dataset component directly instead of using any loop. Here TFDQuery have also Data property but type is different. Earlier in TADOQuery or other Query component, Data property was OleVariant type which was same type like ClientDataset but now it is IFDDataSetReference

So we cannot just assign directly like.

Clientdataset1.Data := FDQuery.Data; //will result an error //

Above code will compile successfully but will result “Invalid data packet” error at runtime. In this scenario we have to use TDatasetProvider as mediator to transfer data from once dataset to another. We can use DatasetProvider.Data property like follow.

DataSetProvider1.Dataset := FDQuery1;
FdQuery1.Open;
Clientdataset1.data := DatasetProvider1.data;

15. Extra points to check

a. Need to change some numeric fields to TBCDFields when it will show error and set Size=2 when in Database field type is like number(15,2)

b. Check SQL statement for “. If it is like “DBA.Segments” which is wrong then it should be “DBA”.”Segment” or DBA.Segments

Comments

  1. Hello, I have a great development with IBX, many years of work and maintenance, I installed delphi XE10 and I cannot get it to work with the version of IBX that it brings. I am analyzing the options ... Keep trying to make it work, for example obtaining previous versions of IBX, which I still cannot get, or migrate everything to FireDac ... time that I do not have ... What you propose is interesting, although you have heard talk about reFind.exe? Have you tried using it? It is a embarcadero tool, there are instructions to migrate from other components but not from IBX, have you analyzed it? What is your opinion?

    ReplyDelete
  2. Well TIBDATSET are very powerfull in IBX what should they be replace of in FireDac

    ReplyDelete
  3. Do have ideas about the equivalent in FireDAC for TIBSQLParser? Thanks.

    ReplyDelete

Post a Comment

Popular posts from this blog

MS Excel Automation in Delphi

ShellExecute in Delphi

Drawing Shapes in Delphi