Examples¶
This section provides complete, working examples of migration XML files for common scenarios.
Minimal DDF-Based Migration (MSSQL)¶
This example migrates tables using existing DDFs. Only overrides are specified.
<?xml version="1.0" encoding="utf-8"?>
<Btrieve2SqlMigration Driver="SQL_BTR">
<!-- Global defaults for all tables -->
<Table Name="" Schema="dbo" OverwriteExistingTable="y"
RememberServerName="y" EraseTableBeforeCopy="y">
<MSSQLBulkCopy BulkCopyByRowCount="500" LockTable="y"/>
</Table>
<!-- Override: make field C1 nullable and set a default -->
<Table Name="Person" Schema="dbo">
<MSSQLBulkCopy BulkCopyByRowCount="1000" LockTable="y"/>
<Fields>
<Field Name="C1" Nullable="y" Default="0"/>
</Fields>
</Table>
</Btrieve2SqlMigration>
Minimal Full Migration (MSSQL)¶
This example fully defines a single table without DDFs.
<?xml version="1.0" encoding="utf-8"?>
<Btrieve2SqlFullMigration Driver="SQL_BTR">
<Table Name="inventry" Filename="inventry.dat" Schema="dbo"
RequireBtrieveFile="n" PageSize="4096" RecordSize="58"
PrimaryIndex="0" VariableLength="n" TrueNullable="n"
OverwriteExistingTable="y" MakeIndexesUnique="y">
<Fields>
<Field Name="InvUnique" BtrDataType="15" Offset="0" Size="4" />
<Field Name="Cat" BtrDataType="0" Offset="4" Size="4" />
<Field Name="Part" BtrDataType="0" Offset="8" Size="50" />
</Fields>
<Indices>
<Index Number="0" Unique="y" PrimaryKey="y">
<Segment Number="1" Field="InvUnique" Size="4" IgnoreCase="n" Descending="n"/>
</Index>
<Index Number="1" Unique="n" PrimaryKey="n">
<Segment Number="1" Field="Part" Size="50" IgnoreCase="y" Descending="n"/>
</Index>
</Indices>
</Table>
</Btrieve2SqlFullMigration>
Oracle Migration with Tablespaces¶
This example targets Oracle and includes tablespace and storage configuration.
<?xml version="1.0" encoding="utf-8"?>
<Btrieve2SqlMigration Driver="ORA_BTR" ContinueOnError="y">
<!-- Global Oracle settings -->
<Table Name="" Schema="" OverwriteExistingTable="y"
RememberServerName="y" EraseTableBeforeCopy="y">
<OracleTableSpaces Table="DATA_TS" Index="INDEX_TS" VarRecs="BLOB_TS"/>
<OracleTableStorage PercentFree="10" PercentUsed="85" Initial="8" Next="1"/>
</Table>
<!-- Specific table with field overrides -->
<Table Name="Customer" Schema="">
<OracleTableSpaces Table="DATA_TS" Index="INDEX_TS"/>
<OracleTableStorage PercentFree="10" PercentUsed="85" Initial="8" Next="1"/>
<Fields>
<Field Name="CustID" Nullable="n" SqlDataType="identity"/>
</Fields>
<Indices>
<Index Number="0" Unique="y" PrimaryKey="y">
<Segment Number="1" Field="CustID" IgnoreCase="n" Descending="n"/>
</Index>
</Indices>
</Table>
</Btrieve2SqlMigration>
Full Migration with Multiple Data Types¶
This example shows a variety of Btrieve data types and field options.
<?xml version="1.0" encoding="utf-8"?>
<Btrieve2SqlFullMigration Driver="SQL_BTR">
<Table Name="invoice" Filename="invoice.dat" Schema="dbo"
RequireBtrieveFile="n" PageSize="4096" RecordSize="43"
PrimaryIndex="0" VariableLength="n" TrueNullable="n"
OverwriteExistingTable="y" MakeIndexesUnique="y"
SqlCollation="Latin1_General_BIN2">
<Fields>
<!-- Auto-increment primary key -->
<Field Name="InvUnique" BtrDataType="15" Offset="0"
Size="4" Modifiable="n"/>
<!-- Null-terminated string -->
<Field Name="InvNo" BtrDataType="11" Offset="4" Size="21"/>
<!-- Single-byte flag -->
<Field Name="InvType" BtrDataType="0" Offset="4" Size="1"/>
<!-- 8-byte float -->
<Field Name="GLTotal" BtrDataType="2" Offset="26" Size="8"
Decimals="2"/>
<!-- Btrieve date and time -->
<Field Name="DatePrinted" BtrDataType="3" Offset="34" Size="4"/>
<Field Name="TimePrinted" BtrDataType="4" Offset="38" Size="4"/>
<!-- Unsigned binary flag -->
<Field Name="Flags" BtrDataType="14" Offset="42" Size="1"/>
</Fields>
<Indices>
<Index Number="0" Unique="y" PrimaryKey="y">
<Segment Number="1" Field="InvUnique" Size="4"
IgnoreCase="n" Descending="n"/>
</Index>
</Indices>
</Table>
</Btrieve2SqlFullMigration>
SQL Script Generation¶
To generate a SQL script instead of executing migration directly, set the SqlScriptFilename attribute on the root element:
<Btrieve2SqlFullMigration Driver="SQL_BTR"
SqlScriptFilename="c:\output\create_tables.sql">
<Table Name="MyTable" Filename="myfile.dat" Schema="dbo">
<!-- ... -->
</Table>
</Btrieve2SqlFullMigration>
The migration tool writes the generated DDL statements to the specified file path.
Single-Field Override¶
The simplest possible DDF-based XML — override one field setting:
<Btrieve2SqlMigration Driver="SQL_BTR">
<Table Name="Updates">
<Fields>
<Field Name="C1" Nullable="n"/>
</Fields>
</Table>
</Btrieve2SqlMigration>