/******************************************************************************* ** ** Source File Name = migrate.c 1.2 ** ** Licensed Materials - Property of IBM ** ** (C) COPYRIGHT International Business Machines Corp. 1995, 1999 ** All Rights Reserved. ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp. ** ** ** PURPOSE : ** an example showing how to use the Migrate API in order to migrate ** a database. ** ** APIs USED : ** MIGRATE DATABASE sqlemgdb ** ** STRUCTURES USED : ** sqlca ** ** OTHER FUNCTIONS DECLARED : ** 'C' COMPILER LIBRARY : ** stdio.h - printf ** ** internal : ** ** external : ** check_error : Checks for SQLCODE error, and prints out any ** [in util.c] related information available. ** This procedure is located in the util.c file. ** ** EXTERNAL DEPENDENCIES : ** - Ensure existence of database for precompile purposes. ** - Compile and link with the IBM Cset++ compiler (AIX and OS/2) ** or the Microsoft Visual C++ compiler (Windows) ** or the compiler supported on your platform. ** ** For more information about these samples see the README file. ** ** For more information on programming in C, see the: ** - "Programming in C and C++" section of the Application Development Guide ** For more information on Building C Applications, see the: ** - "Building C Applications" section of the Application Building Guide. ** ** For more information on the SQL language see the SQL Reference. ** *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sqlenv.h> #include "util.h" #ifdef DB268K /* Need to include ASLM for 68K applications */ #include <LibraryManager.h> #endif #define CHECKERR(CE_STR) if (check_error (CE_STR, &sqlca) != 0) return 1; int main (int argc, char *argv[]) { struct sqlca sqlca; /******************************************* the first argument is the database name, the second argument is the user name, the third argument is the password. *******************************************/ #ifdef DB268K /* Before making any API calls for 68K environment, need to initial the Library Manager */ InitLibraryManager(0,kCurrentZone,kNormalMemory); atexit(CleanupLibraryManager); #endif if (argc != 4) { printf ("\nUSAGE: migrate databasename username password\n\n"); return 1; } /*****************************\ * MIGRATE DATABASE API called * \*****************************/ sqlemgdb (argv[1], argv[2], argv[3], &sqlca); if (sqlca.sqlcode != SQLE_RC_MIG_OK) CHECKERR ("MIGRATE DATABASE"); printf ("Migrate Database completed successfully\n"); }