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

  1. static unsigned char sqla_program_id[40] = 
  2. {111,65,65,66,65,67,66,67,84,71,82,65,89,32,32,32,68,51,48,65,
  3. 67,66,68,49,99,65,117,81,74,68,72,72,32,32,32,32,32,32,32,32};
  4.  
  5.  
  6. #ifdef LINT_ARGS
  7.  
  8.  short far pascal sqlaaloc(unsigned short,
  9.                            unsigned short,
  10.                            unsigned short,
  11.                            void far *);
  12.  short far pascal sqlacall(unsigned short,
  13.                            unsigned short,
  14.                            unsigned short,
  15.                            unsigned short,
  16.                            void far *);
  17.  short far pascal sqladloc(unsigned short,
  18.                            void far *);
  19.  short far pascal sqlasets(unsigned short,
  20.                            unsigned char far *,
  21.                            void far *);
  22.  short far pascal sqlasetv(unsigned short,
  23.                            unsigned short,
  24.                            unsigned short,
  25.                            unsigned short,
  26.                            void far *,
  27.                            void far *,
  28.                            void far *);
  29.  short far pascal sqlastop(void far *);
  30.  short far pascal sqlastrt(void far *,
  31.                            void far *,
  32.                            struct sqlca far *);
  33.  short far pascal sqlausda(unsigned short,
  34.                            struct sqlda far *,
  35.                            void far *);
  36.  
  37. #else
  38.  
  39.  short far pascal sqlaaloc( );
  40.  short far pascal sqlacall( );
  41.  short far pascal sqladloc( );
  42.  short far pascal sqlasets( );
  43.  short far pascal sqlasetv( );
  44.  short far pascal sqlastop( );
  45.  short far pascal sqlastrt( );
  46.  short far pascal sqlausda( );
  47.  
  48. #endif
  49.  
  50. /**********************************       ********   PAGE 1   */
  51. /*                                                                         */
  52. /*  APPLICATION PROGRAM NAME:  D30ACBD1.SQC                                */
  53. /*                                                                         */
  54. /*  PROGRAM LANGUAGE: 'C' Language with Embedded SQL                       */
  55. /*                                                                         */
  56. /*  PROGRAM DESCRIPTION:                                                   */
  57. /*            D30ACBD1 uses 'C' language to create indexes on all          */
  58. /*            tables in the BANK database, and to do runstats              */
  59. /*            using the newly created indexes. The following functions     */
  60. /*            of SHELBY  are tested:                                       */
  61. /*                                                                         */
  62. /*                 START DB  (SHARED)                 (3.2.10)             */
  63. /*                 RESTART DB                                              */
  64. /*                 STOP DB                            (3.2.11)             */
  65. /*                 DATA TYPES: NUMERICAL              (3.3.5.1)            */
  66. /*                 DATA TYPES: CHARACTER              (3.3.5.2)            */
  67. /*                 IMBEDDED SQL                       (3.9.1)              */
  68. /*                       EXEC SQL                     (3.9.1.1)            */
  69. /*                       BEGIN/END DECLARE            (3.9.1.2)            */
  70. /*                       INCLUDE                      (3.9.1.3)            */
  71. /*                       WHENEVER                     (3.9.1.5)            */
  72. /*                       SELECT                       (3.6.1)              */
  73. /*                       ROLLBACK                     (3.6.10)             */
  74. /*                       CREATE INDEXEX                                    */
  75. /*                       RUNSTATS                                          */
  76. /*                 'C' LANGUAGE INTERFACE             (3.11.1)             */
  77. /*                       LANGUAGE RESTRICTIONS        (3.11.1.2)           */
  78. /*                       SPECIAL COMMANDS             (3.11.1.3)           */
  79. /*                       PRECOMPILER                  (3.11.1.4)           */
  80. /*                       DB ENVIRONMENT               (3.11.1.4)           */
  81. /*                       ERROR MSG                    (3.11.1.4)           */
  82. /*                                                                         */
  83. /*  AUTHOR:   S. L. Pettit                   DATE: 11/01/87                */
  84. /*                                                                         */
  85. /*  DATA BASE:                                                             */
  86. /*            SHELBY 3 BANK database                                       */
  87. /*                  - CREDITS table     - LOAN table                       */
  88. /*                  - DEBITS table      - SAVINGS table                    */
  89. /*                  - CUSTOMER table    - BOX table                        */
  90. /*                  - CHECKING table                                       */
  91. /*                                                                         */
  92. /*  INPUT FILES: NONE                                                      */
  93. /*                                                                         */
  94. /* ***************    PROLOG CONTINUED NEXT PAGE    ********************** */
  95.  
  96. /* ** PROLOG CONTINUED ************       ********   PAGE 2   */
  97. /*                                                                         */
  98. /*                                                                         */
  99. /*  OUTPUT FILES:                                                          */
  100. /*            D30ACBD1.ERR - This is a file, written to disk, only when    */
  101. /*            some unexpected error condition is returned from SQL.  It    */
  102. /*            serves as an error log, recording the error code, its cor-   */
  103. /*            responding error message, and any other useful information   */
  104. /*            which the program might be able to give.                     */
  105. /*                                                                         */
  106. /*  DEPENDENCIES:                                                          */
  107. /*            INVICTA, SHELBY 3 DATABASE KERNEL,                           */
  108. /*            database manager started                                     */
  109. /*            creation of SHELBY 3 BANK database,                          */
  110. /*            creation of all tables in BANK database,                     */
  111. /*            precompiling and binding with SQLPREP                        */
  112. /*            compilation with IBM C Compiler 2.0, using compiler options: */
  113. /*                     "/AL /Gs /DLINT_ARGS /DSQL_REL_10 /W3 /Od "         */
  114. /*                                                                         */
  115. /*  FUNCTION CALLS:                                                        */
  116. /*            COMPILER LIBRARY                                             */
  117. /*                 stdio.h - fopen,fclose,fgets,fprintf                    */
  118. /*                 string.h - strcpy                                       */
  119. /*            SHELBY 3 LIBRARY                                             */
  120. /*                 sql.h - sqlaintp; sqlenv - sqlestrd,sqlestpd,sqlerest   */
  121. /*                 sqlenv.h - sqleisig (ctrl-break processing)             */
  122. /*            OTHER                                                        */
  123. /*                 none                                                    */
  124. /*                                                                         */
  125. /*  ERROR CONDITIONS:                                                      */
  126. /*        'C' NORMAL - specifically tested for and handled by the ap-      */
  127. /*                     plication program:                                  */
  128. /*                        log error, exit thru "end" routine.              */
  129. /*                                                                         */
  130. /*       SQL  ABNORMAL - unexpected and resulting in program termination:  */
  131. /*                        log error, exit thru "ret_code" & "end" routine  */
  132. /*                       -1015   Restart Database                          */
  133. /*                                                                         */
  134. /*  MODIFICATIONS:                                                         */
  135. /*            Date      Author         Description                         */
  136. /*                                                                         */
  137. /*          10/26/87    D.J.Grant      Added SQLEISIG function call, and   */
  138. /*                                     enhances exit_error to also print   */
  139. /*                                     SQLERRD[0] - [5] and SQL_ERRP.      */
  140. /*          11/30/87    W.B.Brown      Add prolog                          */
  141. /*          02/03/89    W.B.Brown      Upgrade for release 3.0             */
  142. /***************************************************************************/
  143.  
  144. #include <stdio.h>
  145. #include <string.h>
  146. #include <sql.h>
  147. #include <sqlenv.h>
  148. #include <sqlutil.h>
  149.  
  150.  
  151. /*
  152. EXEC SQL INCLUDE sqlca;
  153. */
  154.  
  155. /* SQL Communication Area - SQLCA - structures and constants */
  156.  
  157. #ifndef SQLCODE
  158.  
  159. /* SQL Communication Area - SQLCA */
  160. struct sqlca
  161. {
  162.    unsigned char  sqlcaid[8];           /* Eyecatcher = 'SQLCA   ' */
  163.    long           sqlcabc;              /* SQLCA size in bytes = 136 */
  164.    long           sqlcode;              /* SQL return code */
  165.    short          sqlerrml;             /* Length for SQLERRMC */
  166.    unsigned char  sqlerrmc[70];         /* Error message tokens */
  167.    unsigned char  sqlerrp[8];           /* Diagnostic information */
  168.    long           sqlerrd[6];           /* Diagnostic information */
  169.    unsigned char  sqlwarn[8];           /* Warning flags */
  170.    unsigned char  sqlext[8];            /* Reserved */
  171. };
  172.  
  173. #define   SQLCODE        sqlca.sqlcode
  174. #define   SQLWARN0       sqlca.sqlwarn[0]
  175. #define   SQLWARN1       sqlca.sqlwarn[1]
  176. #define   SQLWARN2       sqlca.sqlwarn[2]
  177. #define   SQLWARN3       sqlca.sqlwarn[3]
  178. #define   SQLWARN4       sqlca.sqlwarn[4]
  179. #define   SQLWARN5       sqlca.sqlwarn[5]
  180. #define   SQLWARN6       sqlca.sqlwarn[6]
  181. #define   SQLWARN7       sqlca.sqlwarn[7]
  182.  
  183. #endif
  184.  
  185. struct sqlca sqlca;
  186.  
  187.  
  188.  
  189. #define LABELLEN   16       /* statement label length for error logging    */
  190.                             /*    15 characters + string null              */
  191.  
  192. unsigned char msgbuf[512];
  193. unsigned char s_label[LABELLEN];
  194. unsigned char database[] = "BANK";             /* database name            */
  195. unsigned char password[] = "";                 /* password to database     */
  196. unsigned char errfile[] = "D30ACBD1.ERR";      /* error file DOS name      */
  197. unsigned char errpterm[9] = "        ";        /* Null terminated string   */
  198.                                                /* for printing sqlerrp     */
  199. unsigned char customer[] = "DBSYSADM.CUSTOMER";
  200. unsigned char box[] = "DBSYSADM.BOX";
  201. unsigned char checking[] = "DBSYSADM.CHECKING";
  202. unsigned char savings[] = "DBSYSADM.SAVINGS";
  203. unsigned char loan[] = "DBSYSADM.LOAN";
  204. unsigned char credits[] = "DBSYSADM.CREDITS";
  205. unsigned char debits[] = "DBSYSADM.DEBITS";
  206.  
  207. /***************************************************************************/
  208. /* SQL DECLARE SECTION -  For this program none are declared.              */
  209. /***************************************************************************/
  210.  
  211.  
  212. /*
  213. EXEC SQL BEGIN DECLARE SECTION;
  214. */
  215.  
  216.  
  217.  
  218. /*
  219. EXEC SQL END DECLARE SECTION;
  220. */
  221.  
  222.  
  223. /***************************************************************************/
  224.  
  225.  
  226. int main (void);
  227. main ()
  228. {
  229.    FILE *ptr_error;              /* declare error file                     */
  230.    int errorlevel = 0;           /* to be returned to DOS                  */
  231.    short rc = 0;                 /* return code from sqlaintp (error mes-  */
  232.                                  /*    sage retrieval function)            */
  233.    unsigned char *ptr_idxlist[2];
  234.    int numidx;
  235.  
  236. install_sig:
  237.    strcpy (s_label, "install_sig:");
  238.    sqleisig (&sqlca);                       /* Install DBM supplied signal */
  239.                                             /* handling routine.           */
  240.    if (sqlca.sqlcode != 0)
  241.    {
  242.       goto exit_error;
  243.    }
  244.  
  245.    
  246. /*
  247. EXEC SQL
  248.         WHENEVER SQLERROR GOTO exit_error;
  249. */
  250.  
  251.    
  252. /*
  253. EXEC SQL
  254.         WHENEVER SQLWARNING CONTINUE;
  255. */
  256.  
  257.    
  258. /*
  259. EXEC SQL
  260.         WHENEVER NOT FOUND CONTINUE;
  261. */
  262.  
  263.  
  264. start_db:
  265.    sqlestrd (database,password,'S',&sqlca); /* Start using specified DB,   */
  266.                                             /* with specified password, in */
  267.                                             /* shared mode.                */
  268.    if (sqlca.sqlcode == -1015)              /* If the database needs to be */
  269.    {                                        /*   restarted, due to previ-  */
  270.       strcpy (s_label,"restart:");          /*   ous system failure, issue */
  271.       sqlerest (database,password,&sqlca);  /*   restart, followed by      */
  272.       if (sqlca.sqlcode != 0)               /*   another start using.      */
  273.       {
  274.          goto exit_error;
  275.       }
  276.       sqlestrd (database,password,'S',&sqlca);
  277.    }
  278.    strcpy(s_label,"start_db:   ");
  279.    if (sqlca.sqlcode != 0)
  280.    {
  281.       goto exit_error;
  282.    }
  283.  
  284. create_index1:
  285.    strcpy(s_label,"create_index1:");
  286.  
  287.    printf ("\n CREATING BOX INDEX ON BOX NUMBER \n");
  288.  
  289.  
  290.    
  291. /*
  292. EXEC SQL
  293.         CREATE UNIQUE INDEX IDX_B_NUMB ON BOX (B_NUMB);
  294. */
  295.  
  296. {
  297.   sqlastrt(sqla_program_id,0L,&sqlca);
  298.   sqlacall((unsigned short)24,1,0,0,0L);
  299. if (sqlca.sqlcode < 0)
  300. {
  301.    sqlastop(0L);
  302.    goto exit_error;
  303. }
  304.  
  305.   sqlastop(0L);
  306. }
  307.  
  308.  
  309. create_index2:
  310.    strcpy(s_label,"create_index2:");
  311.  
  312.    printf ("\n CREATING LOAN INDEX ON LOAN NUMBER \n");
  313.  
  314.    
  315. /*
  316. EXEC SQL
  317.         CREATE UNIQUE INDEX IDX_L_NUMB ON LOAN (L_NUMB);
  318. */
  319.  
  320. {
  321.   sqlastrt(sqla_program_id,0L,&sqlca);
  322.   sqlacall((unsigned short)24,2,0,0,0L);
  323. if (sqlca.sqlcode < 0)
  324. {
  325.    sqlastop(0L);
  326.    goto exit_error;
  327. }
  328.  
  329.   sqlastop(0L);
  330. }
  331.  
  332.  
  333. create_index3:
  334.    strcpy(s_label,"create_index3:");
  335.  
  336.    printf ("\n CREATING LOAN INDEX ON LOAN SSN \n");
  337.  
  338.    
  339. /*
  340. EXEC SQL
  341.         CREATE INDEX IDX_L_SSN ON LOAN (L_SSN);
  342. */
  343.  
  344. {
  345.   sqlastrt(sqla_program_id,0L,&sqlca);
  346.   sqlacall((unsigned short)24,3,0,0,0L);
  347. if (sqlca.sqlcode < 0)
  348. {
  349.    sqlastop(0L);
  350.    goto exit_error;
  351. }
  352.  
  353.   sqlastop(0L);
  354. }
  355.  
  356.  
  357. create_index4:
  358.    strcpy(s_label,"create_index4:");
  359.  
  360.    printf ("\n CREATING SAVINGS INDEX ON SAVINGS NUMBER \n");
  361.  
  362.    
  363. /*
  364. EXEC SQL
  365.         CREATE UNIQUE INDEX IDX_S_ACCNUMB ON SAVINGS (S_ACCNUMB);
  366. */
  367.  
  368. {
  369.   sqlastrt(sqla_program_id,0L,&sqlca);
  370.   sqlacall((unsigned short)24,4,0,0,0L);
  371. if (sqlca.sqlcode < 0)
  372. {
  373.    sqlastop(0L);
  374.    goto exit_error;
  375. }
  376.  
  377.   sqlastop(0L);
  378. }
  379.  
  380.  
  381. create_index5:
  382.    strcpy(s_label,"create_index5:");
  383.  
  384.    printf ("\n CREATING SAVINGS INDEX ON SAVINGS SSN \n");
  385.  
  386.    
  387. /*
  388. EXEC SQL
  389.         CREATE INDEX IDX_S_SSN ON SAVINGS (S_SSN);
  390. */
  391.  
  392. {
  393.   sqlastrt(sqla_program_id,0L,&sqlca);
  394.   sqlacall((unsigned short)24,5,0,0,0L);
  395. if (sqlca.sqlcode < 0)
  396. {
  397.    sqlastop(0L);
  398.    goto exit_error;
  399. }
  400.  
  401.   sqlastop(0L);
  402. }
  403.  
  404.  
  405. create_index6:
  406.    strcpy(s_label,"create_index7:");
  407.  
  408.    printf ("\n CREATING CHECKING INDEX ON CHECKING SSN1 \n");
  409.  
  410.    
  411. /*
  412. EXEC SQL
  413.         CREATE INDEX IDX_C_SSN1 ON CHECKING (C_SSN1);
  414. */
  415.  
  416. {
  417.   sqlastrt(sqla_program_id,0L,&sqlca);
  418.   sqlacall((unsigned short)24,6,0,0,0L);
  419. if (sqlca.sqlcode < 0)
  420. {
  421.    sqlastop(0L);
  422.    goto exit_error;
  423. }
  424.  
  425.   sqlastop(0L);
  426. }
  427.  
  428.  
  429. create_index7:
  430.    strcpy(s_label,"create_index7:");
  431.  
  432.    printf ("\n CREATING CREDITS INDEX ON CREDITS NUMBER \n");
  433.  
  434.    
  435. /*
  436. EXEC SQL
  437.         CREATE INDEX IDX_CR_ACCNUMB ON CREDITS (CR_ACCNUMB);
  438. */
  439.  
  440. {
  441.   sqlastrt(sqla_program_id,0L,&sqlca);
  442.   sqlacall((unsigned short)24,7,0,0,0L);
  443. if (sqlca.sqlcode < 0)
  444. {
  445.    sqlastop(0L);
  446.    goto exit_error;
  447. }
  448.  
  449.   sqlastop(0L);
  450. }
  451.  
  452.  
  453. create_index8:
  454.    strcpy(s_label,"create_index8:");
  455.  
  456.    printf ("\n CREATING DEBITS INDEX ON DEBITS NUMBER \n");
  457.  
  458.    
  459. /*
  460. EXEC SQL
  461.         CREATE INDEX IDX_DB_ACCNUMB ON DEBITS (DB_ACCNUMB);
  462. */
  463.  
  464. {
  465.   sqlastrt(sqla_program_id,0L,&sqlca);
  466.   sqlacall((unsigned short)24,8,0,0,0L);
  467. if (sqlca.sqlcode < 0)
  468. {
  469.    sqlastop(0L);
  470.    goto exit_error;
  471. }
  472.  
  473.   sqlastop(0L);
  474. }
  475.  
  476.  
  477.  
  478. runstat1:
  479.    strcpy(s_label,"runstat1:");
  480.    ptr_idxlist[0] = "DBSYSADM.IDX_B_NUMB";
  481.    numidx = 1;
  482.  
  483. // printf ("\n RUNSTATS ON BOX NUMBER INDEX \n");
  484.  
  485. //   sqlustat (box, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  486. //   if (sqlca.sqlcode != 0)
  487. //   {
  488. //      goto exit_error;
  489. //   }
  490.  
  491. runstat2:
  492.    strcpy(s_label,"runstat2:");
  493.    ptr_idxlist[0] = "DBSYSADM.IDX_L_NUMB";
  494.    ptr_idxlist[1] = "DBSYSADM.IDX_L_SSN";
  495.    numidx = 2;
  496.  
  497. // printf ("\n RUNSTATS ON LOAN NUMBER AND SSN \n");
  498.  
  499. //   sqlustat (loan, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  500. //   if (sqlca.sqlcode != 0)
  501. //   {
  502. //      goto exit_error;
  503. //   }
  504.  
  505. runstat3:
  506.    strcpy(s_label,"runstat3:");
  507.    ptr_idxlist[0] = "DBSYSADM.IDX_S_ACCNUMB";
  508.    ptr_idxlist[1] = "DBSYSADM.IDX_S_SSN";
  509.    numidx = 2;
  510.  
  511. // printf ("\n RUNSTATS ON SAVINGS NUMBER AND SSN \n");
  512.  
  513. // sqlustat (savings, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  514. // if (sqlca.sqlcode != 0)
  515. // {
  516. //    goto exit_error;
  517. // }
  518.  
  519. runstat4:
  520.    strcpy(s_label,"runstat4:");
  521.    ptr_idxlist[0] = "DBSYSADM.IDX_C_SSN1";
  522.    numidx = 1;
  523.  
  524. // printf ("\n RUNSTATS ON CHECKING NUMBER AND SSN1 \n");
  525.  
  526. // sqlustat (checking, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  527. // if (sqlca.sqlcode != 0)
  528. // {
  529. //    goto exit_error;
  530. // }
  531.  
  532. runstat5:
  533.    strcpy(s_label,"runstat5:");
  534.    ptr_idxlist[0] = "DBSYSADM.IDX_CR_ACCNUMB";
  535.    numidx = 1;
  536.  
  537. // printf ("\n RUNSTATS ON CREDITS NUMBER INDEX \n");
  538.  
  539. //   sqlustat (credits, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  540. //   if (sqlca.sqlcode != 0)
  541. //   {
  542. //      goto exit_error;
  543. //   }
  544.  
  545. runstat6:
  546.    strcpy(s_label,"runstat6:");
  547.    ptr_idxlist[0] = "DBSYSADM.IDX_DB_ACCNUMB";
  548.    numidx = 1;
  549.  
  550. // printf ("\n RUNSTATS ON DEBITS NUMBER INDEX \n");
  551.  
  552. //   sqlustat (debits, numidx, ptr_idxlist, 'B', 'R', &sqlca);
  553. //   if (sqlca.sqlcode != 0)
  554. //   {
  555. //      goto exit_error;
  556. //   }
  557.  
  558.    goto exit_normal;
  559.  
  560.  
  561.  
  562. exit_error:
  563.                                             /* if unable to open errfile,  */
  564.                                             /* write messages to screen.   */
  565.    if ((ptr_error = fopen(errfile, "w")) == NULL)
  566.    {
  567.       printf ("\nUNABLE TO OPEN D30ACBD1.ERR\n");
  568.       printf ("%s   SQLCODE IS %ld\n",s_label,sqlca.sqlcode);
  569.       goto continue_err;
  570.    }
  571.    fprintf (ptr_error,"%s\n",s_label);     /* write error information to   */
  572.                                            /* file.                        */
  573.    fprintf (ptr_error,"SQLCODE IS %ld\n",sqlca.sqlcode);
  574.    fprintf (ptr_error,"SQLERRD[0] IS %ld\n",sqlca.sqlerrd[0]);
  575.    fprintf (ptr_error,"SQLERRD[1] IS %ld\n",sqlca.sqlerrd[1]);
  576.    fprintf (ptr_error,"SQLERRD[2] IS %ld\n",sqlca.sqlerrd[2]);
  577.    fprintf (ptr_error,"SQLERRD[3] IS %ld\n",sqlca.sqlerrd[3]);
  578.    fprintf (ptr_error,"SQLERRD[4] IS %ld\n",sqlca.sqlerrd[4]);
  579.    fprintf (ptr_error,"SQLERRD[5] IS %ld\n",sqlca.sqlerrd[5]);
  580.    memcpy (errpterm,sqlca.sqlerrp,8);
  581.    fprintf (ptr_error,"SQLERRP IS %s\n",errpterm);
  582.    rc = sqlaintp (msgbuf,512,50,&sqlca);   /* call error message retreival */
  583.    if (rc < 0)                             /* -- retrieve failed.          */
  584.    {
  585.       fprintf (ptr_error,"SQLAINTP ERROR.   Return code = %d",rc);
  586.    }
  587.    else if (rc > 0)                        /* -- retrieve successful.      */
  588.         {
  589.            fprintf (ptr_error,msgbuf);
  590.         }
  591.    fclose (ptr_error);                     /* close error file             */
  592.  
  593. continue_err:
  594.    errorlevel = 2;
  595.    
  596. /*
  597. EXEC SQL                                /- reset sqlerror handling to   -/
  598.         WHENEVER SQLERROR CONTINUE;
  599. */
  600.         /*  prevent endless error loop  */
  601.                                            /*  if rollback should fail.    */
  602.    
  603. /*
  604. EXEC SQL
  605.         ROLLBACK WORK;
  606. */
  607.  
  608. {
  609.   sqlastrt(sqla_program_id,0L,&sqlca);
  610.   sqlacall((unsigned short)28,0,0,0,0L);
  611.   sqlastop(0L);
  612. }
  613.  
  614.  
  615.    if (sqlca.sqlcode != 0)                 /* If error, add on to already  */
  616.                                            /* created errfile.  If unable  */
  617.                                            /* to open, write to screen.    */
  618.    {
  619.       if ((ptr_error = fopen(errfile, "a")) == NULL)
  620.       {
  621.          printf ("\nUNABLE TO OPEN D30ACBD1.ERR -- ROLLBACK FAILED.");
  622.          goto exit_normal;
  623.       }
  624.       fprintf (ptr_error,"\nSQLCODE IS %ld,  ROLLBACK FAILED.",sqlca.sqlcode);
  625.       fclose (ptr_error);
  626.    }
  627.  
  628. exit_normal:
  629.    sqlestpd (&sqlca);                      /* stop using the database      */
  630. end:
  631.    return(errorlevel);
  632. }
  633.