Mertech Blog

Write Your Own Migration Routines Using the CONVERT_DAT_FILE Macro

Written by Mertech | Feb 16, 2009 6:16:00 PM

Mertech provides a macro, CONVERT_DAT_FILE that can be called from a DataFlex program using the Mertech.inc file. This macro will migrate a DataFlex file to the target backend, creating table and index structures and copying data using the default settings of the GUI database migration tool.

Using CONVERT_DAT_FILE, you can write your own custom migration routines to handle migrations at remote sites.

For a full description of CONVERT_DAT_FILE see the Mertech Command Reference (mertech.inc.html)  installed in (<programfiles>Mertech Data SystemsDB DriversDataFlex help)


Example

Use Mertech.inc
login <Server> <User> <Password> <Driver>
//For SQLFlex, MySQLFlex or PgFlex
if (sDataBase <> "NULL") Begin
  SET_DATABASE_NAME to sDataBase
  SQL_USE_DATABASE     sDataBase
  End
If (Err) Begin
  Showln "Login Error !"
  Inkey Pageend
End
MERTECH_WARNING_MESSAGE DISABLED
open "customer" as customer
CONVERT_DAT_FILE customer.file_number
close customer
Showln
Showln "Done ..."
Inkey Pageend

 

Note: If you are using Mertech V12 drivers, you can also programatically determine how the driver handles table and field names: a) convert to upper case, b) convert to lower case, or c) keep all cases as stored in Dataflex (default). For additional information see  Mertech Tech Tips - Case Handling

Note: For the migration process, the Oracle user must have CONNECT, RESOURCE and DBA rights. This is required because ORAFlex needs to access some views and tables in SYS schema to define the extends and storage for creating the new table.