On October 17, I did an InterBase webinar on using Change Views to simplify data change tracking. Change Views allows you to reduce your network traffic, keep mobile data costs down and speed up your development time by syncing only the changes you subscribe to.
As your database scales, the data tracking hurdles get larger and require complex solutions, triggers, timestamp tables and more. There’s a simpler way for you to take control of your data syncs: InterBase Change Views.
InterBase Change Views takes a new approach to tracking your data changes on both the client and server side. Designed for syncing in the mobile world, Change Views allows you to rethink the methods and constraints that data change tracking offers by reducing your technique planning and development time while maintaining a fast, highly scalable secure database engine.
Code snippets
Creating a Change View in IBConsole
When in IBConsole, click on Subscriptions and Create Subscription adding in details or in ISQL add the following code changing your tables names:
CREATE SUBSCRIPTION "SUB_MEDICINEUPDATES" ON "CATEGORY" FOR ROW (INSERT, UPDATE, DELETE), "MEDICINE" FOR ROW (INSERT, UPDATE, DELETE), "MEDICINE_CATEGORIES" FOR ROW (INSERT, UPDATE, DELETE) DESCRIPTION 'Track inserts, updates and deletes to medicine data'; Privileges for accessing tables GRANT SUBSCRIBE ON SUBSCRIPTION <subscription_name> TO <user_name> REVOKE SUBSCRIBE ON SUBSCRIPTION <subscription_name> TO <user_name>
Working with Change Views in RAD Studio
procedure TdtmdlDelta.OpenAll(ID : string; ShowMerged : Boolean); begin // Local connection in Cached Update Modes qryCategory.CachedUpdates := True; qryMedicine.CachedUpdates := True; qryMedicineCategories.CachedUpdates := True; qryCategory.Open(); qryMedicine.Open(); qryMedicineCategories.Open(); if FDTransactionDelta.Active then FDTransactionDelta.Rollback; FDTransactionDelta.StartTransaction; // Start the transaction to fetch the deltas. - this changes from Select ALL to Select subscribed changes only. qrySubscriptionActive.SQL.Text := Format('set subscription sub_medicineupdates at ''%s'' active;',[ID]); qrySubscriptionActive.ExecSQL; qryCategoryDelta.Open(); qryMedicineDelta.Open(); qryMedicineCategoriesDelta.Open(); procedure TdtmdlDelta.PostDeltas; begin qryCategory.MergeDataSet(qryCategoryDelta, TFDMergeDataMode.dmDeltaMerge, mmUpdate); qryMedicine.MergeDataSet(qryMedicineDelta, TFDMergeDataMode.dmDeltaMerge, mmUpdate); qryMedicineCategories.MergeDataSet(qryMedicineCategoriesDelta, TFDMergeDataMode.dmDeltaMerge, mmUpdate); qryCategory.ApplyUpdates; qryMedicine.ApplyUpdates; qryMedicineCategories.ApplyUpdates; FDTransactionDelta.Commit;
Additional Resources
- More information and Free Trial: www.embarcadero.com/products/interbase
- RAD Studio DocWiki: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Main_Page
- Change Views: docwiki.embarcadero.com/InterBase/en/Change_Views
- Samples: docwiki.embarcadero.com/CodeExamples/en/Category:Sample
- Change Views: docwiki.embarcadero.com/InterBase/en/Change_Views
- FireDAC & InterBase
- FAQ: docwiki.embarcadero.com/RADStudio/en/InterBase_Servers_Questions_(FireDAC)
- License Installation & Deployment:
Sample Application used in webinar : C:\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\Object Pascal\Database\FireDAC\Samples\DBMS Specific\InterBase
Some answers to your Q&A questions
Which versions of InterBase support Change Views subscriptions?
The InterBase Server, Desktop and ToGo editions support Change Views subscriptions.
What is the cost of an InterBase ToGo license?
The list price for InterBase ToGo is $64 USD. Please reach out to your local sales representative for further pricing.
Does Change Views needs to be configured on both client and server?
You set up your Change Views subscription in IBConsole then configure it in your application. Check out the webinar video for which components you need to use in RAD Studio for Change Views.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition