/*******************************************************************************
**
** Source File Name = dbstart.c 
**
** Licensed Materials - Property of IBM
**
** (C) COPYRIGHT International Business Machines Corp. 1995, 2000 
** All Rights Reserved.
**
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
**
**
**  PURPOSE : to start a database manager
**
**    APIs USED :
**       START DATABASE MANAGER             sqlepstart
**
**    STRUCTURES USED :
**       sqlca
**
**    OTHER FUNCTIONS USED :
**       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 <sqlenv.h>
#include <sqlca.h>
#include "utilapi.h"


int main (int argc, char *argv[]) {
   struct sqlca sqlca;
   int rc;
   /***********************************\
   * START DATABASE MANAGER API called *
   \***********************************/
   rc = sqlepstart (NULL, &sqlca);
   if (rc != SQL_RC_OK)  { 
      if (rc == SQLE_RC_INVSTRT) 
         printf ("The database manager is already active.\n");
      return 0;
#ifdef DB2AIX
   } else {
      API_SQL_CHECK("START DATABASE MANAGER");
      if (sqlca.sqlcode > 0) {
         printf ("Warning ONLY.  DATABASE has been STARTED\n");
         return 1;
      } else if (sqlca.sqlcode < 0) {
         printf ("ERROR.  DATABASE has NOT been STARTED\n");
         return 1;
      } /* endif */
#endif
   } /* endif */

   printf ("The database has been successfully STARTED\n");
   return 0;
}