home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / DBDEMO.ZIP / DEMODB.ZIP / D30ACBA2.C < prev    next >
Text File  |  1991-06-03  |  4KB  |  132 lines

  1.  
  2. /*   *********************************************************************   */
  3. /*
  4.      D30ACBA2.C is a program with only one function: to update the database
  5.      configuration file.
  6.  
  7.      The changes made will be to the log file size and to the application
  8.      heap size.
  9.  
  10.      Log file size will be changed to 200 - 4k pages.
  11.  
  12.      Application heap size will be changed to 6.                */
  13.  
  14. /***************************************************************************/
  15. /*                                                                         */
  16. /*  MODIFICATIONS:                                                         */
  17. /*            Date      Author         Description                         */
  18. /*                                                                         */
  19. /*                                                                         */
  20. /*          12/10/87    D.J.Grant      Added SQLEISIG function call, and   */
  21. /*                                     enhances exit_error to also print   */
  22. /*                                     SQLERRD[0] - [5] and SQL_ERRP.      */
  23. /*          02/06/89    W.B.Brown      Upgraded to run on Release 3.0.     */
  24. /*                                                                         */
  25. /*                                                                         */
  26. /***************************************************************************/
  27.  
  28.  
  29.  
  30. #include <stdio.h>
  31. #include <sql.h>
  32. #include <sqlenv.h>
  33. #include <sqlutil.h>
  34. #include <sqlca.h>
  35. #include <sqlcodes.h>
  36. #include <memory.h>
  37. #include <string.h>
  38.  
  39. struct sqlca sqlca;
  40.  
  41. unsigned char msg_buf[512];
  42. unsigned char rte_label[16] = "               ";
  43. unsigned char dbase[] = "BANK";
  44. unsigned char password[] = "";
  45. unsigned char errfile[] = "D30ACBA2.ERR";
  46.  
  47. unsigned char  sqlerrp_value[9] = "        ";             /* error value  */
  48.  
  49. int errlevel = 0;
  50.  
  51.     short rc = 0;                    /*  From sqlaintp - initialize to 0     */
  52.  
  53.  
  54.  
  55.  
  56. /*  ** BEGIN MAIN FUNCTION  *******       ********              */
  57.  
  58. int main (void);
  59. main ()
  60. {
  61. /*   Declare output error file                                               */
  62.  
  63.      FILE *ptr_errfile;
  64.  
  65. /*   Declare a short integer to receive the return code message length-SQL   */
  66. /*   (Error file is open for error, therefore (-1) is used for open.)        */
  67. /*   Declare a short integer to indicate dbase open(0) or failed (-1).       */
  68.  
  69.  
  70.     struct sqlfupd chglst[2];
  71.         unsigned long opt4;
  72.         unsigned short opt7;
  73.  
  74.     opt4 = 200;
  75.     opt7 = 6;
  76.  
  77.     chglst[0].token = 4;
  78.     chglst[0].ptrvalue = (char *)&opt4;
  79.  
  80.     chglst[1].token = 7;
  81.     chglst[1].ptrvalue = (char *)&opt7;
  82.  
  83.  
  84.   strcpy(rte_label,"instal sqleisig");
  85.  
  86.   sqleisig(&sqlca);                             /* ctrl-break processing     */
  87.  
  88.   if (sqlca.sqlcode != 0)
  89.     {
  90.      goto ret_code;
  91.     }
  92.  
  93.  
  94. /*    ********************************************************************   */
  95.  
  96.     sqlfeudb (dbase,password,2,chglst,&sqlca);
  97.  
  98.    ret_code:
  99.  
  100.     if (sqlca.sqlcode != 0)
  101.      {
  102.  
  103.     ptr_errfile = fopen(errfile, "w");
  104.     fprintf(ptr_errfile,"\nSQLERRD[0] is %ld",sqlca.sqlerrd[0]);
  105.     fprintf(ptr_errfile,"\nSQLERRD[1] is %ld",sqlca.sqlerrd[1]);
  106.     fprintf(ptr_errfile,"\nSQLERRD[2] is %ld",sqlca.sqlerrd[2]);
  107.     fprintf(ptr_errfile,"\nSQLERRD[3] is %ld",sqlca.sqlerrd[3]);
  108.     fprintf(ptr_errfile,"\nSQLERRD[4] is %ld",sqlca.sqlerrd[4]);
  109.     fprintf(ptr_errfile,"\nSQLERRD[5] is %ld",sqlca.sqlerrd[5]);
  110.  
  111.     memcpy (sqlerrp_value, sqlca.sqlerrp, 8);
  112.     fprintf(ptr_errfile,"\nSQLERRP is %s",sqlerrp_value);
  113.  
  114.        if ((rc = sqlaintp(msg_buf,512,0,&sqlca)) > 0)
  115.         {
  116.          fprintf(ptr_errfile,"SQLCODE IS %ld\n",sqlca.sqlcode);
  117.          fprintf(ptr_errfile,msg_buf);
  118.          fclose(ptr_errfile);
  119.         }
  120.         else
  121.          {
  122.           fprintf(ptr_errfile,"SQLCODE IS %ld\n",sqlca.sqlcode);
  123.           fclose(ptr_errfile);
  124.          }
  125.  
  126.          errlevel = 2;
  127.         }
  128.  
  129.    return(errlevel);
  130.  
  131. }                                                     /* END MAIN FUNCTION   */
  132.