Product Documentation

SQL Operations Guide

Previous Topic

Next Topic


The FairCom DB SQL Migration Utility requires two ‘C’ source files, ctsqlmgr.c and migrfncs.c, which can be modified extensively, as described below, to meet the exact needs of your application. These two files can be found in ctreeSDK\ctreeAPI\ctree\samples\special\sqlmigr. To compile the program, you will need to generate and link against a c-tree Plus single user standalone library with c-treeDB API support and transaction processing.

The logic of the migration utility is in ctsqlmgr.c, and this is the module to which you will add any customized code. The migrfncs.c file can be modified as well, although this should not be necessary under normal circumstances. The core of the migrate.c module is the following function:

MigrateTable(pCTDBSESSION hSession, pTEXT orig, pTEXT dest, MigrationInfo *fconv).

This function takes a pointer, hSession, to a c-treeDB API session which is currently logged in, the source file name, orig, the destination file name, dest, and a pointer to a structure containing information about the migration process, fconv. The majority of your customizations will be located in this MigrationInfo structure. It may be necessary to add custom logon information for your particular installation. That information is located outside of this structure.

If the migration structure is not provided to the MigrateTable() function (i.e., fconv is set to NULL), the code internally populates a MigrationInfo structure based on the default implementation described above.

The MigrationInfo structure is defined in migrfncs.c and described as follows.

typedef struct _MigrationInfo


/* callbacks */

MigrFunc AfterRecRead;

MigrFunc AfterRecWrite;

MigrFunc AfterRecConv;

MigrFunc BeforeOpens;

MigrFunc BeforeFirst;

/* ErrMsgFunc */

ErrMsgFunc ErrorMessage;

/* memory usage */

ULONG memoryKB;

/* source/dest objects */

pCTDBTABLE hSourceTbl;




/* field mapping */

FieldMap *fmap;

/* internals */

pTEXT strBuffer;

VRLEN strSize;

pCTBLOB pBlob;

} MigrationInfo;