Icon Saving Updates To and Loading Updates From Databases

Saving updates to databases and loading updates from databases is accomplished by using the TEDBSession Execute method to execute the SAVE UPDATES, SET UPDATES STORE, and LOAD UPDATES statements. You can also attach event handlers to the TEDBSession OnStatusMessage and OnProgress events in order to track any status messages and progress during a save or load operation.

Saving the updates to a database copies the updates to all or some of the tables within the database to a compressed or uncompressed update file in a local store. Loading the updates from a database applies the updates from all or some of the tables in a compressed or uncompressed update file in a local store into the database.

In order to save the updates for a given table or tables in a database, the database table(s) must be published first using the PUBLISH DATABASE statement. Please see the Publishing and Unpublishing Databases topic for more information.

Saving the Updates for a Database
When the updates are saved, a read lock is obtained for all tables whose updates are being saved that prevents any sessions from performing any writes to any of the involved tables in the database until the save completes. However, since the saving of the updates is quite fast, the time during which the tables cannot be changed is usually pretty small. To ensure that the database is available as much as possible for updating, it is recommended that you save the database updates to a file in a local store on a fast hard drive and then copy the file to a store that references a CD, DVD, or other slower device outside of the scope of the database being locked instead of creating the update file directly in the store on the slower device.

The following example shows how to save the updates for a database called "MyDatabase" using the SAVE UPDATES statement and the TEDBSession Execute method:

begin
   MySession.Execute('SAVE UPDATES FOR DATABASE "MyDatabase" '+
                     'AS "MyDatabase-Updates-'+
                        Engine.DateToSQLStr(Date)+'" '+
                     'TO STORE "Updates"');
end;

Information You cannot specify a remote store as the location for the update file. It must be a local store. Please see the Creating and Using Stores for more information on stores.

Tracking the Progress of the Saving

To take care of tracking the progress of the saving we have provided the OnProgress and OnStatusMessage events within the TEDBSession component. The OnProgress event will report the progress of the saving operation and the OnStatusMessage event will report any status messages regarding the saving operation.

Retrieving Information from an Update File
To retrieve information about the update files in a specific store, you can use the SET UPDATES STORE statement to specify the store where the update files are located, and then use a SELECT statement to query the Updates Table in the Configuration Database. The Updates table contains information about all of the update files in the store specified by the SET UPDATES STORE statement, with one row per update file. Please see the Executing SQL Statements for more information on executing a query.

Loading the Updates for a Database
When the updates are loaded, a write lock is obtained for all of the tables specified for the load that prevents any sessions from performing any reads or writes to any of the specified tables until the load completes. However, since the execution of a load is quite fast, the time during which the tables cannot be accessed is usually pretty small.

Information Update files from the same source database should always be loaded in their creation order. For example, if you have 3 update files that have come from two different copies of the database, then the 2 update files from one of the source databases should be loaded in their creation order. The other update file doesn't matter because updates from different source databases can be loaded in any order. You can find out the creation order by querying the Updates table in the Configuration database, as described above in the Retrieving Information from an Update File section.

The following example shows how to load the updates for a database called "MyDatabase" using the LOAD UPDATES statement and the TEDBSession Execute method:

begin
   MySession.Execute('LOAD UPDATES FOR DATABASE "MyDatabase" '+
                     'FROM "MyDatabase-Updates-'+
                        Engine.DateToSQLStr(Date)+'" '+
                     'IN STORE "Updates"');
end;

Information You cannot specify a remote store as the location for the update file. It must be a local store. Please see the Creating and Using Stores for more information on stores.

Tracking the Progress of the Loading

To take care of tracking the progress of the loading we have provided the OnProgress and OnStatusMessage events within the TEDBSession component. The OnProgress event will report the progress of the load operation and the OnStatusMessage event will report any status messages regarding the load operation.
Image