Migrating Files using the Command-line

A command-line tool, MdsMigrateTable, can be used instead of the BTR2SQL GUI Migration Utility to migrate an existing Btrieve application to work with an SQL server.

MdsMigrateTable

You can use MdsMigrateTable to do all the work (create tables, copy data, create indexes), or you can create the tables and indexes and copy the data with another tool, or only create an SQL script to create the tables.

MdsMigrateTable reads the Btrieve table definitions from the Pervasive Data Definition Files (DDFs).

Command-line syntax

Select Mertech’s ISDBC Drivers for Btrieve | Mds Migrate Table from the Windows Start menu. Since this is a command-line utility, a Command Prompt is automatically opened

Run the MdsMigrateTable script by typing the following at the command prompt:

MdsMigrateTable tablelist operation ddf [configuration parameters]

Tablelist determines which Btrieve tables are involved in the migration process. The tablelist parameter is required.

Table List

Description

OneTable

Perform the selected task on one Btrieve table. Use the /table parameter to pass the table name.

AllTables

Perform the selected task on the entire Btrieve database.

AllConfig

Perform the selected task on the defined Btrieve tables. Use the /config parameter to pass the name of the XML document that defines the configuration for the migration.

Operation determines which piece(s) of the migration to perform. The operation parameter is required.

Operation

Description

CreateTable

Only create the tables, indexes and INT files on the server.

CopyData

Only copy the Btrieve data to the SQL server (indexes are dropped, data is copied, then the indexes are restored). Assumes the tables were already created on the SQL server.

Full

Create the tables, indexes and INT files and copy the data.

IntOnly

Only create the INT files.

ScriptOnly

Only generate the SQL script that can be used to create the tables.

NOTE: INT files are created in the same location as the data files unless they are redirected to another folder by the mds.ini file.

ddf is the full or relative path to the data dictionary files (DDFs). The ddf parameter provides the source for the conversion and is required.

/ddf <DDF Folder>

Configuration parameters are settings used during the migration process. Configuration parameters are optional unless otherwise indicated.

Configuration Parameter

Description

/server <servername>

Destination SQL server and optional port number where the server is listening for communication. Always use the same SQL server version as the end-user. For instance, migrating to MS2008 utilizes different data types than MS2005.

/database <dbname>

Destination database.

/schema <schema>

Destination database schema. Normally the database owner.

/user <username>

User name for server login (empty for trusted connection).

/password <password>

Password for server login.

/table <tablename>

Name of table to migrate (as listed in the DDFs). /table is required if tablelist is OneTable.

/dll <Mertech migration dll>

The path and filename of the Mertech migration dll (sql_btr.dll, ora_btr.dll, or pgs_btr.dll) used to access the SQL backend. If the full path is not specified, the dll is loaded from the system PATH.

/config <xml config filename>

XML document that defines the configuration for the migration. If NULL, the default settings are used. /config is required if tablelist is AllConfig.

/trace <trace filename>

Path and filename for the trace output.

/level <trace level>

Level of tracing (-2, -1, 0, 1, 2, 3, 4).

/nopause

Do not wait for a key press at end.

NOTE: If the server, target database, and/or login credentials are not provided, the mds.INI file, registry settings, or Login dialog box provide these details.

XML Config File

The /config parameter can be used to pass the name of an XML config file that contains settings that affect the conversion process. For instance, whether to remember the server name in the INT file, the Oracle tablespace settings, or whether a field is nullable. If no /config parameter is provided the driver’s default settings and the information obtained from the DDFs and the data file itself are used.

You can use the XML config file to override default conversion settings. You only need to include the pieces to be changed. For example, if you want to change one of the fields to not be nullable even though the DDFs are flagged as nullable you might provide the following XML config file.

<Btrieve2SqlMigration Driver="SQL_BTR">

  <Table Name="Updates">

    <Fields>

     <Field Name="C1" Nullable="n"/>

    </Fields>

  </Table>

</Btrieve2SqlMigration>

A Table entry with no table Name specified overrides the default settings for ALL tables. A Table entry with a specific Name indicated overrides the default settings. So you can have a no table name entry with OverwriteExistingTable=yes and then for table “person”, specify OverwriteExistingTable=no.

If you are migrating a uniPaaS application and the source is stored in XML format, you can generate the XML config file automatically using the MigrateUniPaasData command-line tool. You can then edit the generated file to meet your needs. You can also create the XML config file manually.

NOTE: Refer to the <Program Files>\Mertech Data Systems\DB Drivers\Btrieve\sdk\samples\migration folder for sample XML files and the DTD, which contains the legal building blocks for the XML config file.

Migration Validator

Run MigrationValidator after data is migrated to verify that everything was correctly transferred from the Btrieve application to the SQL server. Migration Validator checks that the basic table structure and indexes match and then reads all the records from Btrieve and from SQL to verify the data was successfully stored.

A message displays in the output if any mismatch is found.

Prerequisites

1. BTR2SQL or some other tool has copied all of the data from the Btrieve database into the desired SQL backend.

2. The data has not been modified in either version of the database. Otherwise, the tool will incorrectly report failures, such as mismatched data or incorrect number of rows.

3. The Pervasive version of w3btrv7.dll is expected to be present in the system PATH. You can accomplish this most efficiently by copying the original dll from your pvsw\bin folder into the folder where MigrationValidator.exe is located.

Command-line Syntax

Select Mertech’s ISDBC Drivers for Btrieve | Migration Validator from the Windows Start menu. Since this is a command-line utility, a Command Prompt is automatically opened.

Run the Migration Validator script by typing the following at the command prompt:

MigrationValidator <database location> [-dll <Mertech dll>] [-table
<tablelist>] [-maxRows <n>] [/varOnly] [/debug]

Database location : Is required and indicates the path to the DDFs. The DDFs are read for schema information, then each table in the list is opened and tested.

-dll: Specifies the full path and filename (wbtrv32, w3btrv7, or sql_btr) of the dll used to access the SQL backend. If no dll is specified, sql_btr.dll is loaded from the system PATH.

-table: Lists the table(s) to be tested. By default, all tables are tested. When you include the -table parameter, you can specify one or more tables to limit the test. Use semicolons to separate the list, or include the ‑table parameter multiple times.

-maxRows: Allows you to shorten the testing time by reducing the number of rows checked.

/varOnly: Only tables with variable length records are tested if this parameter is included.

/debug: Additional processing information is displayed if this parameter is included.

Example:

MigrationValidator c:\mydata\demodata -dll "C:\Program Files\Mertech Data Systems\DB Drivers\Btrieve\bin\ora_btr.dll" -table person;billing;class-maxRows 2000