1
I am researching how the auto increment fields work in Firedac, using Delphi xE7 and managed to assemble an example of the documentation that synchronizes two master-details tables with the correct key. The doubt arose when I wanted to make a mirror of my Firebird server on Sqlite, as I will distribute an application that needs not only work offline, as well as persist the data when closing the application.
Then in my remote application I will add records in two tables (Pedidos
,Itens
) in master-detail schema, which need to have a foreign key in common. When connecting to the server at the end of the day I want to send
orders and new items, knowing that there may be other users who have also generated Sqlite keys the same as mine. Using Firedac, how to update them with new keys without losing the master-detail link?
Remembering that the server is Firebird and locally is Sqlite...
Dear Edison. Thank you very much for the comment. Unfortunately this is not the point. Firedac has so many smart features with keys and transactions that there must be a better method to do this without touching the bank. Remembering that it is important for my project to centralize the rules of business in Delphi. We know for example that Firedac manages key generation when it works offline, with commit. And it works even with master-detail tables. Now, regarding INSERT INTO tab1 values (...) RETURNING idpk, I don’t know how to take advantage of this being the server offline. Any idea?
– Ricardo da Rocha Vitor
It will depend on how the software is structured, considering that its remote part will not have online integration with the server, one way to have this "unique key" is using UUID. Reference in link
– Edison de Brito