Local (Offline) Storage (Magic xpa 2.x)
The RIA client supports local data sources. Using a local data source, you can save data on the client and use it later on, mainly in Offline programs that do not access the server.
Using local storage can also improve performance by locally caching data. This completes the Offline offering by providing the ability to locally store a subset of server data, and to synchronize it to the server later on.
The local database is defined by setting the DBMS column in the Database repository to Local (in the same way that a DBMS is set to MicrosoftSQLServer or Memory, for example).
A local DBMS database’s data source is a client data source, and will be stored locally in the client cache.
The following limitations apply to local databases and data sources:
-
A local database cannot be used in a Direct SQL statement.
-
A local data source can only be used in Rich Client tasks. (It cannot be used in Online, Batch, or Browser tasks.)
-
The transaction for local data sources behaves as a physical transaction. All the tasks that include a local data source will be in the same transaction. (This is planned to be changed in future versions.)
-
Commit of the local data is done according to the task that opened the transaction. If a transaction is also opened in sibling tasks, then the data of these tasks will also be committed. (This is planned to be changed in future versions.)
-
Rolling back a task that has a local data source will roll back:
-
All the tasks that have a local data source. (This is planned to be changed in future versions.)
-
The deferred transaction of a parent task.
-
A local data source cannot be used in a task that has a Tree control.
-
A task cannot have mixed server and local data sources. (This is planned for a future release.)
The following features are not supported for local databases and data sources:
-
Unique Index or ROWID SQL Position values
-
A Link Join operation between local data sources
-
Sync Data on a Call operation
-
Range on a position
-
SQL Range
-
Index optimization
-
User Sort and Magic Sort
-
Deferred transactions
-
Get Definition utility
-
Change Tables in Studio database property
-
Error handlers – It is not possible to define error handlers for local data source errors.
-
Chunk size
When a change is made to the structure of a local data source (such as deleting a field, modifying a field picture, or adding a field), the change is automatically applied to the client’s local data source after the project metadata is transferred to the client.
The existing local data is automatically converted to the new structured data source if possible.
If a change in the local data source structure invalidates some of the data (such as adding a unique index or changing a string field to a numeric one), this data will be lost. Therefore, it is recommended to avoid making such changes if you need the local data.
Note that the conversion from the old structure to the new one is done based on the data source’s ISN. This means that if the local data source was renamed in the Studio, it will also be renamed in the local database. If you want your original local data source to remain unchanged, you need to create a new data source for the new structure.