RECASTDB

RECASTDB is used to copy structure information and data in selected tables from one database to another.

See Transferring the Database Structure in the DP4 Developer's Manual for further information about using this program to transfer database structure, and Transferring Data for information on using it to transfer ordinary database data.

From 4.620 RECASTDB can also be used to synchronise a "local" or "satellite" database (for example one stored on a Windows CE PDA) with a "master" database (for example one stored on a Web Server accessed via a Dial up internet connection). The term "satellite" is preferred to "local" because in some modes of operation, the "local" database will actually be remote! With synchronisation data transfer may be two way. In what follows "upload" refers to data transfer from the "satellite" to the "master" database, and "download" refers to the reverse operation. The "source" database is the database from which data is currently being copied, and the "target" database the one to which this data is copied, or from which it is deleted. The terms "upload" and "download" are used regardless of the actual method of data transfer − both uploads and downloads can be achieved by running RECASTDB at either side of a network connection - in one case end the data will be pushed to the other,in the other it will be pulled from the other. Wherever possible you should choose to push data as this will generally be much faster and consume less network resource.

Synchronisation can be controlled using information contained in a configuration file, the name of which is specified as a command line option when RECASTDB is started. It is envisaged that several different configuration files might be created to synchronise databases in different ways.

The synchronisation facilities of RECASTDB are not currently intended to cope with the situation where both databases may contain inconsistent updates to the same table.

Principles of Operation

Prior to release 4.620 the method used to reconcile two databases is as follows:

If RECASTDB is being used to synchronise databases held on different machines accessed via a slow network these methods can cause RECASTDB to run very slowly. In 4.620 there are options that cause RECASTDB to use alternate algorithms that may well result in its running much faster.

Command Tails for RECASTDB

Command Tail Description

−APPL

This option omits the structure change part of synchronisation when the −distributed or −synchronise options are in use. This command line option is not available if a configuration file is used and the corresponding option must be specified in the configuration file instead.

−BYNAME

Transfer data where fields or tables have different internal numbers. Compatibility test by name only. This option should not be used when synchronising databases (in theory it ought to work, but it has not been tested except for making changes to two local databases)

−CONFIG filename

Specifies the name of a configuration file that describes how RECASTDB is to run. The configuration file is read from the local machine. If no path is specified it is assumed to be in the same direction as the other DP4 configuration files. This option is only intended for use with the −synchronise and −distributed options. 4.62x only

−COPYALL

When copying tables this option suppresses the test for whether the record is already present. This option is not used if a configuration file is used, and is currently only implemented in the 4.62x RECASTDB.

−COPYDB

This command tail causes recastdb to do a structure transfer from the from database to the to database. The transfer is purely a dictionary transfer - no maps, QAB or Report Writer programs etc. are transferred. In addition there is no warning if REORGDB will be required afterwards. This option, introduced in release 4.622/4.526, is intended to simplify the upgrade process for systems using the "split database" facility. Typically when upgrading you issue a new "program" database, and need to apply the structure of this database to the existing "data" database. You will usually want also to specify the −quiet option when using this option.

−DB name

Specify the database to use with the −synchronise or −distributed options

−DELETEALL

When deleting tables this suppresses the test for whether the record is present on the source database. All data is deleted from the target database. This option is not used if a configuration file is used, and is currently only implemented in the 4.62x RECASTDB.

−DISTRIBUTED

Selects a special mode of operation that transfers structure and data between a local and a remote copy of the same database. You must be running either a local resilience or multiple resilience network configuration for this option to work. Normally, this option will be used in conjunction with a configuration file. If no configuration file is specified tables marked as "local table only" (when viewed with makedb −expert) are downloaded, and tables not so marked are uploaded. (This may well seem to be back to front,the rationale is that a "local table" is usually used to store fairly static data to reduce the need to access a remote database, and a not "local only" table is only updated locally when the "master" database is offline. The "local table only" settings are ignored when a configuration file is used, and if you are not using them already you are recommended to ignore them.

−FROMDB name

Specify the database to transfer from (not used with the −synchronise or −distributed options)

−LOCALMASTER

Informs the −synchronise option that the server specified in the −synchronise option is a "satellite" database, and that the default server is the "master" database (by default the opposite is assumed).

−NODD

When transferring structure information, omits dictionary tables. This is only safe if the data dictionaries are already identical.

−NODOWNLOAD

Omits the transfer of changes from the "master" to the "local" database. This command line option is not available if a configuration file is used and the corresponding option must be specified in the configuration file instead.

−NOMESSAGE

Suppresses the message about REORGDB being required which may be generated when doing a structure transfer. Added in 4.526/4.622

−NOUPLOAD

Omits the transfer of changes from the "local" to the "master" database. This command line option is not available if a configuration file is used and the corresponding option must be specified in the configuration file instead.

−QUIET

Reduces screen output to a minimum during the MAKELINK phase of structure transfer. This may improve performance significantly, especially on Microsoft Windows (running RECASTDB minimised will also speed things up.)

−REMOTECONFIG filename

This option is only available with the −synchronise option and specifies the name of a configuration file that describes how RECASTDB is to run. The configuration file is read from the machine specified in the servername value specified with −synchronise. If no path is specified it is assumed to be in the same direction as the other DP4 configuration files. This option will not work if TCPMGR is loaded with the −nocopy option.

−RUNONLY

Restrict copying of QA Build tables to those required by PROGRUN

−SYNCHRONISE servername

Selects a special mode of operation that transfers structure and data between a local and a remote copy of the same database. You must be running with a networked configuration of DP4 that supports named connections, i.e. using a TCP/IP network requester in in one of the following configurations:

  • a simple client
  • a local resilence client
  • a named connection configuration
The last of these is probably the best option to use as it becomes possible to organise for upload and download to be done simultaneously with RECASTDB being run with an upload only configuration at the satellite machine and a download only configuration at the master. Normally, this option will be used in conjunction with a configuration file. If no configuration file is specified tables are copied in the same way as is described for the −distributed option.

−TODB name

Specify the database to transfer to (not used with the −synchronise or −distributed options)

RECASTDB configuration files

A RECASTDB configuration file allows you to gain a very high degree of control over the operation of RECASTDB. In many cases using a configuration file will allow you to synchronise data between two different copies of a database without the need for writing special programs.

The configuration files are formatted like a Windows INI file. There are a number of sections, demoted by headings in square brackets, and each section contains entries in the form key=value.

Global options are specified in the [defaults] section. For each table that is copied RECASTDB also looks in the [tablename.download] or [tablename.upload] sections for table specific settings. Default values for several of these options are taken from the [upload] and [download] sections.

[defaults] section

appl=1 Omits the structure transfer phase of synchronisation. If appl=0 is specified explicitly, a partial structure transfer is performed. However the dictionary tables are not transferred − i.e. the −NODD option is always in effect for synchronisation.
check_structure=1 Before transferring data RECASTDB normally checks the structure of tables is compatible on both databases. If the check_strucure=0 option is specified this check is omitted. This option should only be used where you are absolutely certain the databases have identical dictionaries, and the structure check will take too long, for instance if you are running over a very slow WAN or internet connection.
download=1 If the value is 1 the download phase of synchronisation is performed. If it is 0 it is not. Ideally download should be performed by running RECASTDB on the "master" machine using the −synchronise and −local master options. This will significantly reduce the amount of data transfer over the network and hence gives improved performance. The −reverse option of tcpmgr can be used to automatically launch a script or other program that can then call RECASTDB like this to transfer data (you may even launch RECASTDB directly, but you may want to run another program that will decide whether or not to run RECASTDB based on the date or time or information held on the master database.).
upload=0 If the value is 1 the upload phase of synchronisation is performed. If it is 0 it is not. Ideally download upload be performed by running RECASTDB on the "local" machine using the −synchronise option. This will significantly reduce the amount of data transfer over the network and hence gives improved performance.

[upload] and [download] sections

These sections contain entries that set default values for the table specific options. These values will be used for tables for which no values is specified for the corresponding entry in the table specific section.
copy=1 If copy=1 tables are uploaded or downloaded by default, even if they are not referred to in the configuration file.
delete=download If delete=1 tables are processed for deletion by default, even if they are not referred to in the configuration file. This option defaults to 1 for the [download] section and 0 for the [upload] section.
mode=0 If mode=0 is specified all records selected from tables on the source database are copied. If mode=1 is specified then only records matching specified table specific conditions are processed. The condition defaults to "all", so it does not matter if you don't specify a condition for a particular table.
use_timestamp=download If use_timestamp=0 is specified all records selected from tables on the source database are copied, subject to the other conditions, if any, specified for the table. If use_timestamp=1 is specified then in addition to the other conditions, records for upload are excluded unless their timestamp indicates that they have been created/updated on the satellite since the last synchronisation, and records for download are excluded unless their timestamp (on the master) indicates that they have been created/updated on the master.

[tablename.upload] and [tablename.download] sections

Most settings in these sections have the same format in both cases. Settings in the [tablename.upload] section are used when copying a table from the "local" to the "master" database. Settings in the download section are used in the reverse case.

condition=boolean formula This entry, only used when mode=1, specifies the condition used to decide whether to copy a record from the source to the target database.
copy=default_copy If copy=1 the table is uploaded or downloaded in acoordance with the other settings. If copy=0 the table is not copied.
delete=default_delete If delete=1 records are processed for deletion in accordance with the other settings for the table. If delete=0 the table is not processed for deletion.
delete_both=0 This entry, only used when delete=1, causes data that is to be deleted from the target database also to be deleted from the source database.
delete_condition=boolean formula This entry, only used when mode=1, specifies the condition used to decide whether to delete a record from the target database.
index=index_table.index_role
delete_index=index_table.index_role
Normally RECASTDB will search through an entire table when looking for records that should be copied/deleted. You can use this option, together with the index_value/delete_index_value entries to limit the amount of data searched.
index_value=formula
delete_index_value=formula
This specifies the formula to be used for the first keyfield when the index or delete_index entries are used.
mode=default_mode If mode=0 is specified all records selected from the table on the source database are copied. If mode=1 is specified then the condition or delete_condition specified is used to filter records.
set_timestamp=use_timestamp If set_timestamp=0 is specified (or implied) the timestamp associated with synchronisation for this table is not updated. If set_timestamp=1 is specified (or implied because use_timetamp=1) then after a successful synchronisation the timestamp associated with the table on the satellite databases is updated.
update_field=field_name.field_role This specifies a field to be updated on the source database for records that are transferred during an upload (or download, though this is unlikely to be useful). Records are only updated when the transfer succeeds. Unfortunately, it is impossible to absolutely guarantee that the update will be made, though it will only fail in exceptional circumstances.
update_value=formula This specifies a formula that assigns a new value to update_field.
use_timestamp=default_use_timestamp If use_timestamp=0 is specified all records selected from the table on the source database are copied, subject to the other conditions, if any, specified for the table. If use_timestamp=1 is specified then in addition to the other conditions, records for upload are excluded unless their timestamp indicates that they have been created/updated on the satellite since the last synchronisation, and records for download are excluded unless their timestamp indicates that they have been created/updated on the master.