Icon Publishing and Unpublishing Databases

Publishing and unpublishing databases is accomplished by using the TEDBSession Execute method to execute the PUBLISH DATABASE and UNPUBLISH DATABASE statements. You can also attach event handlers to the TEDBSession OnStatusMessage event in order to track any status messages during a publish or unpublish operation.

Publishing a database causes ElevateDB to mark all tables that are included in the publishing as published and begin to log all insert, update, or delete operations on the published tables. ElevateDB then will continue to log all such operations until a SAVE UPDATES statement is executed for the published tables, at which time an update file will be created that contains these logged updates, and then remove the logged updates from the log associated with each published table.

The logging of the updates for a published table works as follows for each type of operation:

OperationDescription
InsertsAll modified columns are logged.
UpdatesThe primary key columns for the pre-update version of the row are logged, and all new modified columns are logged also.
DeletesThe primary key columns for the pre-delete version of the row are logged.

Unpublishing a database causes ElevateDB to mark all tables that are included in the unpublishing as unpublished, and to drop all logged updates for the table, making a backup of the logged updates in the process. The unpublish process effectively undoes the publishing process.

Publishing a Database
When the publish executes, it has to obtain an exclusive lock on all tables that are being published in the specified database. This is due to the fact that publishing a table alters its metadata in the database catalog.

The following example shows how to publish a database called "MyDatabase" using the PUBLISH DATABASE statement and the TEDBSession Execute method:

begin
   MySession.Execute('PUBLISH DATABASE "MyDatabase"');
end;

You can also, optionally, use the TABLES clause of the PUBLISH DATABASE statement to specify a subset of tables in the DATABASE to publish.

Tracking the Publish Progress
To take care of tracking the status of the publishing we have provided the OnStatusMessage event within the TEDBSession component. The OnStatusMessage event will report any status messages regarding the publishing operation.

Unpublishing a Database
When the unpublish executes, it has to obtain an exclusive lock on all tables that are being unpublished in the specified database. This is due to the fact that unpublishing a table alters its metadata in the database catalog.

The following example shows how to unpublish a database called "MyDatabase" using the UNPUBLISH DATABASE statement and the TEDBSession Execute method:

begin
   MySession.Execute('UNPUBLISH DATABASE "MyDatabase"');
end;

You can also, optionally, use the TABLES clause of the UNPUBLISH DATABASE statement to specify a subset of tables in the DATABASE to unpublish.

Retrieving Publishing Information
To retrieve information about which tables are published, an when they were published, you can use a SELECT statement to query the Tables Table in the Information schema in the published database. The Tables table contains information about all of the tables in the published database, with one row per table. Please see the Executing SQL Statements for more information on executing a query.
Image