home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / DBDEMO.ZIP / DEMODB.ZIP / D30ACBC1.C < prev    next >
Text File  |  1991-07-03  |  38KB  |  1,386 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,67,49,105,66,74,73,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. /*                                                                         */
  51. /*  APPLICATION PROGRAM NAME:  D30ACBC1.SQC of D30SCB01                    */
  52. /*                                                                         */
  53. /*  PROGRAM LANGUAGE:  'C' Language                                        */
  54. /*                                                                         */
  55. /*  PROGRAM DESCRIPTION:  D30ACBC1.SQC is the import/create view pgm       */
  56. /*                                                                         */
  57. /*                        This program will create the necessary views     */
  58. /*                        that will be used throughout the BANKING         */
  59. /*                        scenario.                                        */
  60. /*                                                                         */
  61. /*                        In addition, 5 of the 7 tables that form the     */
  62. /*                        the BANK database,  will be filled with actual   */
  63. /*                        data via the Import function.                    */
  64. /*                                                                         */
  65. /*                        The remaining two tables will have their         */
  66. /*                        data filled during D30ACB03.SQC.                 */
  67. /*                                                                         */
  68. /*   AUTHOR:  D. J. Grant                    DATE: 04/17/87                */
  69. /*                                                                         */
  70. /*   DATABASE:   SHELBY 3 BANK database                                    */
  71. /*               Tables:  Customer/Box/Loan/Debits/Credits/Savings/Checking*/
  72. /*                                                                         */
  73. /*   INPUT FILES:  Import files:                                           */
  74. /*                                                                         */
  75. /*                      CUSTOMER.WRK                                       */
  76. /*                      BOX.WR1                                            */
  77. /*                      LOAN.WKS                                           */
  78. /*                      SAVINGS.WKS                                        */
  79. /*                      CHECKING.WK1                                       */
  80. /*                                                                         */
  81. /*   OUTPUT FILES:  D30ACBC1.ERR - this is a file, written to disk, only   */
  82. /*                  when some type of error condition is returned from     */
  83. /*                  SQL.  It serves as an error log, recording the error   */
  84. /*                  code, its corresponding error message, and any other   */
  85. /*                  useful information which the program might be able     */
  86. /*                  to give.                                               */
  87. /*                                                                         */
  88. /*                  CUSTERR   -  is a file that will be created as a       */
  89. /*                  result of an error on the import function for the      */
  90. /*                  CUSTOMER table.  If this file does not exist, it       */
  91. /*                  will be created as a result of the error condition.    */
  92. /*                                                                         */
  93. /*                  Similarly, the following files will be created if      */
  94. /*                  an error occurs during the import function with        */
  95. /*                  regard to the respective tables:  BOXERR, LOANERR      */
  96. /*                  SAVERR, and CHCKERR.                                   */
  97. /*                                                                         */
  98. /* *********************** PROLOGUE CONTINUED NEXT PAGE  ***************** */
  99.  
  100. /* ******************************************     *********** */
  101. /* *********************** PROLOGUE CONTINUED **************************** */
  102. /*                                                                         */
  103. /*                                                                         */
  104. /*   DEPENDENCIES:  INVICTA, SHELBY 3 DATABASE KERNEL,                     */
  105. /*                  creation of SHELBY 3 BANK database,                    */
  106. /*                  pre-compilation with SQLPREP,                          */
  107. /*                  binding to data base with SQLPREP or SQLBIND,          */
  108. /*                  compilation with IBM C/2, using                        */
  109. /*                     compiler options:                                   */
  110. /*                     "/AL /DLINT_ARGS /DSQL_REL_10 /W2 /Od /FPa"         */
  111. /*                                                                         */
  112. /*   FUNCTION CALLS:  'C' COMPILER LIBRARY                                 */
  113. /*                       stdio.h - fopen,fclose,fgets,fprintf              */
  114. /*                       malloc.h - malloc                                 */
  115. /*                       string.h - strcpy                                 */
  116. /*                       memory.h - memcpy                                 */
  117. /*                                                                         */
  118. /*                    SHELBY 3 LIBRARY                                     */
  119. /*                       sql.h - sqlaintp                                  */
  120. /*                       sqlenv.h - sqlestrd,sqlestpd                      */
  121. /*                                - sqleisig (ctrl-break processing)       */
  122. /*                       sqlutil.h - import utility                        */
  123. /*                                                                         */
  124. /*                    OTHER                                                */
  125. /*                       none                                              */
  126. /*                                                                         */
  127. /*  ERROR CONDITIONS:                                                      */
  128. /*            NORMAL - specifically tested for and handled by the ap-      */
  129. /*                     plication program:  (exit_normal)                   */
  130. /*                     DOS (errorlvl) = 0.                                 */
  131. /*                                                                         */
  132. /*            ABNORMAL - unexpected and resulting in program termination:  */
  133. /*                       (exit_error)                                      */
  134. /*                     DOS (errorlvl) = 2.                                 */
  135. /*                                                                         */
  136. /*  MODIFICATIONS:                                                         */
  137. /*            Date      Author         Description                         */
  138. /*                                                                         */
  139. /*            10/05/87  D.J. Grant     - added enhanced exit_error code    */
  140. /*                                         to handle < or > sqlaintp error.*/
  141. /*                                     - added file open error handling    */
  142. /*                                         to display error message on     */
  143. /*                                         screen.                         */
  144. /*                                     - add     to each page.*/
  145. /*                                     - added code to restart database.   */
  146. /*                                     - changed each table import process */
  147. /*                                         to use memcpy to specify the    */
  148. /*                                         tcolumn list, instead of using  */
  149. /*                                         a strcpy.                       */
  150. /*                                     - added DOS return code processing. */
  151. /*                                     - changed all program references to */
  152. /*                                         use new naming conventions.     */
  153. /*          10/26/87    D.J.Grant      Added SQLEISIG function call, and   */
  154. /*                                     enhances exit_error to also print   */
  155. /*                                     SQLERRD[0] - [5] and SQL_ERRP.      */
  156. /*          03/08/88    D.J.Grant      - deleted the ZP compiler option.   */
  157. /*                                     - created new table - NEWCUST.      */
  158. /*                                     - created views - VIEWBOX & VIEWCUST*/
  159. /*          07/28/88    W.B.Brown      - added two views using SET ops     */
  160. /*                                       views will be exported in D30ACB05*/
  161. /*          02/03/89    W.B.Brown      - upgraded to release 3.0           */
  162. /** END OF PROLOGUE ********************************************************/
  163.  
  164. /********************************************     ***************/
  165. /*****************************************************************************/
  166. /*  SET UP INCLUDES                                                          */
  167. /*****************************************************************************/
  168.  
  169. #include <stdio.h>
  170. #include <string.h>
  171. #include <memory.h>
  172. #include <malloc.h>
  173. #include <sql.h>
  174. #include <sqlenv.h>
  175. #include <sqlutil.h>
  176. #include <sqlca.h>
  177.  
  178. /*****************************************************************************/
  179. /*  DEFINITIONS AND DECLARATIONS                                             */
  180. /*****************************************************************************/
  181.  
  182. struct sqlca sqlca;
  183.  
  184. /* Set up error message buffer */
  185.  
  186.         unsigned char msgbuf[512];
  187.  
  188. /* Declarations for D30ACBC1.ERR error file */
  189.  
  190.         unsigned char  errorfle[]="D30ACBC1.err";
  191.         unsigned char   tcaseid[]="Test Case Id : D30ACBC1.SQC";
  192.         unsigned char  descript[]="BANK:  create views & import";
  193.  
  194. /* Declarations for BANK data base */
  195.  
  196.         unsigned char  database[]="bank";   /* establish database name       */
  197.         unsigned char  password[]="";       /* set up null password          */
  198.  
  199. /* Declarations for import filnames */
  200.  
  201.         unsigned char  imp_cust[]="customer.wrk";
  202.         unsigned char  imp_box []="box.wr1";
  203.         unsigned char  imp_loan[]="loan.wks";
  204.         unsigned char  imp_sav []="savings.wks";
  205.         unsigned char  imp_chck[]="checking.wk1";
  206.  
  207.         unsigned char  imptype []="WSF";
  208.  
  209. /* Declarations for import Insert string for tclostrg */
  210.  
  211.         unsigned char  ins_cust[]="INSERT INTO CUSTOMER";
  212.         unsigned char  ins_box []="INSERT INTO BOX     ";
  213.         unsigned char  ins_loan[]="INSERT INTO LOAN    ";
  214.         unsigned char  ins_sav []="INSERT INTO SAVINGS ";
  215.         unsigned char  ins_chck[]="INSERT INTO CHECKING";
  216.         unsigned char  custerr[] = "custerr.msg";
  217.         unsigned char  boxerr[] = "boxerr.msg";
  218.         unsigned char  loanerr[] = "loanerr.msg";
  219.         unsigned char  saverr[] = "saverr.msg";
  220.         unsigned char  chckerr[] = "chckerr.msg";
  221.  
  222. /*****************************************************************************/
  223.  
  224.     unsigned char rte_label[16] = "               ";    /* progress marker   */
  225.     unsigned char  sqlerrp_value[9] = "        ";         /* error value  */
  226.  
  227. /*****************************************************************************/
  228.  
  229. /********************************************     ***************/
  230. int main (void);
  231. main ()
  232. {
  233.  
  234.    FILE *ptr_errorfle;                      /* declare ptr to error fle */
  235.  
  236. /*****************************************************************************/
  237. /* Import information:  The following section sets up the environment for    */
  238. /*      the 5 imports that will be performed during this program.  Maximum   */
  239. /*      pointers and memory allocations will be set up inorder to allow      */
  240. /*      one set up for all 5 imports.                                        */
  241. /*                                                                           */
  242. /*****************************************************************************/
  243.  
  244.         struct sqlchar *tcolstrg;         /* pointer to tcolstrg */
  245.         struct sqlchar *filetmod;          /* declare import structure       */
  246.         struct sqldcol *dcoldata;         /* pointer to dcolumn list */
  247.  
  248.         char   *ptr1, *ptr2, *ptr3;       /* pointers for memory allocation  */
  249.  
  250.         int callerac = 0;
  251.  
  252. /* Program local variables */
  253.  
  254.  
  255.     int errlevel = 0;                        /* return code to DOS call pgm  */
  256.  
  257.     short dbas_cls = 0;                      /* database open/close flag     */
  258.  
  259.     short rc = 0;                            /* variable for return code */
  260.  
  261.  
  262. /*  Allocate storage for sqldcol; the number used in the assignment should   */
  263. /*  be the maximum number of columns for any table.                          */
  264.  
  265.   ptr1 = malloc((sizeof(char))+(sizeof(short))+(10*sizeof(struct sqldcoln)));
  266.  
  267.   dcoldata = (struct sqldcol *)ptr1;
  268.   dcoldata->dcolmeth = 'D';
  269.  
  270.   ptr2 = malloc(22);
  271.  
  272.   tcolstrg = (struct sqlchar *)ptr2;
  273.   tcolstrg->length = 20;
  274.  
  275.   ptr3 = malloc(3);
  276.   filetmod = (struct sqlchar *)ptr3;
  277.  
  278.   filetmod->length = 0;
  279.   filetmod->data[0] = '\0';
  280.  
  281.  
  282. /********************************************     ***************/
  283.  
  284. /*****************************************************************************/
  285. /*  ERROR HANDLING FOR SQL STATEMENTS                                        */
  286. /*****************************************************************************/
  287.  
  288.         
  289. /*
  290. EXEC SQL
  291.              WHENEVER SQLERROR GOTO exit_error;
  292. */
  293.  
  294.         
  295. /*
  296. EXEC SQL
  297.              WHENEVER SQLWARNING CONTINUE;
  298. */
  299.  
  300.         
  301. /*
  302. EXEC SQL
  303.              WHENEVER NOT FOUND CONTINUE;
  304. */
  305.  
  306. /*****************************************************************************/
  307.  
  308.   strcpy(rte_label,"instal sqleisig");
  309.  
  310.   sqleisig(&sqlca);                             /* ctrl-break processing     */
  311.  
  312.   if (sqlca.sqlcode != 0)
  313.     {
  314.      goto exit_error;
  315.     }
  316.  
  317. /***************************************************************************/
  318.  
  319. /*****************************************************************************/
  320. /*  START USING DATABASE                                                     */
  321. /*****************************************************************************/
  322.  
  323.    strcpy(rte_label,"start database ");
  324.  
  325.    start_dbres:
  326.  
  327.     sqlestrd (database,'S',&sqlca);
  328.  
  329.     if (sqlca.sqlcode == -1015)                       /* If start db func    */
  330.     {                                                 /* fails, call restart */
  331.        strcpy(rte_label,"restart databas");           /* func.               */
  332.        sqlerest(database,&sqlca);            /* Check for failed    */
  333.          if (sqlca.sqlcode != 0)                      /* restart; on error   */
  334.             {                                         /* set dbase closed,   */
  335.             dbas_cls = -1;                            /* go to error exit.   */
  336.             goto exit_error;
  337.             }
  338.        strcpy(rte_label,"start database2");
  339.        sqlestrd (database,'S',&sqlca);       /* Good restart-start  */
  340.     }                                                 /* db again.           */
  341.  
  342.     if (sqlca.sqlcode != 0)                           /* Check 2nd start for */
  343.       {                                               /* failure; if failed, */
  344.       dbas_cls = -1;                                  /* set flag to closed. */
  345.       goto exit_error;                                /* Also checks for any */
  346.       }                                               /* other error code on */
  347.                                                       /* 1st sqlestrd.       */
  348.  
  349.  
  350. /********************************************     ***************/
  351.  
  352. /* *****************    ADD FOREIGN KEYS TO TABLES   ********************** */
  353.  
  354.    strcpy(rte_label,"ADD FOREIGN KEY");
  355.  
  356.   
  357. /*
  358. EXEC SQL
  359.      ALTER TABLE SAVINGS FOREIGN KEY SSSN (S_SSN) REFERENCES CUSTOMER
  360.      ON DELETE RESTRICT;
  361. */
  362.  
  363. {
  364.   sqlastrt(sqla_program_id,0L,&sqlca);
  365.   sqlacall((unsigned short)24,1,0,0,0L);
  366. if (sqlca.sqlcode < 0)
  367. {
  368.    sqlastop(0L);
  369.    goto exit_error;
  370. }
  371.  
  372.   sqlastop(0L);
  373. }
  374.  
  375.  
  376.   
  377. /*
  378. EXEC SQL
  379.      ALTER TABLE LOAN FOREIGN KEY LSSN (L_SSN) REFERENCES CUSTOMER
  380.      ON DELETE RESTRICT;
  381. */
  382.  
  383. {
  384.   sqlastrt(sqla_program_id,0L,&sqlca);
  385.   sqlacall((unsigned short)24,2,0,0,0L);
  386. if (sqlca.sqlcode < 0)
  387. {
  388.    sqlastop(0L);
  389.    goto exit_error;
  390. }
  391.  
  392.   sqlastop(0L);
  393. }
  394.  
  395.  
  396.   
  397. /*
  398. EXEC SQL
  399.      ALTER TABLE CHECKING FOREIGN KEY CSSN (C_SSN1) REFERENCES CUSTOMER
  400.      ON DELETE RESTRICT;
  401. */
  402.  
  403. {
  404.   sqlastrt(sqla_program_id,0L,&sqlca);
  405.   sqlacall((unsigned short)24,3,0,0,0L);
  406. if (sqlca.sqlcode < 0)
  407. {
  408.    sqlastop(0L);
  409.    goto exit_error;
  410. }
  411.  
  412.   sqlastop(0L);
  413. }
  414.  
  415.  
  416.   
  417. /*
  418. EXEC SQL
  419.      ALTER TABLE DEBITS FOREIGN KEY DACCT (DB_ACCNUMB) REFERENCES CHECKING
  420.      ON DELETE CASCADE;
  421. */
  422.  
  423. {
  424.   sqlastrt(sqla_program_id,0L,&sqlca);
  425.   sqlacall((unsigned short)24,4,0,0,0L);
  426. if (sqlca.sqlcode < 0)
  427. {
  428.    sqlastop(0L);
  429.    goto exit_error;
  430. }
  431.  
  432.   sqlastop(0L);
  433. }
  434.  
  435.  
  436.   
  437. /*
  438. EXEC SQL
  439.      ALTER TABLE CREDITS FOREIGN KEY CACCT (CR_ACCNUMB) REFERENCES CHECKING
  440.      ON DELETE CASCADE;
  441. */
  442.  
  443. {
  444.   sqlastrt(sqla_program_id,0L,&sqlca);
  445.   sqlacall((unsigned short)24,5,0,0,0L);
  446. if (sqlca.sqlcode < 0)
  447. {
  448.    sqlastop(0L);
  449.    goto exit_error;
  450. }
  451.  
  452.   sqlastop(0L);
  453. }
  454.  
  455.  
  456.   
  457. /*
  458. EXEC SQL COMMIT;
  459. */
  460.  
  461. {
  462.   sqlastrt(sqla_program_id,0L,&sqlca);
  463.   sqlacall((unsigned short)21,0,0,0,0L);
  464. if (sqlca.sqlcode < 0)
  465. {
  466.    sqlastop(0L);
  467.    goto exit_error;
  468. }
  469.  
  470.   sqlastop(0L);
  471. }
  472.  
  473.  
  474. /*   ***********************  GRANT PRIVILEGES  ***************************  */
  475.  
  476.    strcpy(rte_label,"REVOKE PUBLIC  ");
  477.  
  478.    
  479. /*
  480. EXEC SQL
  481.       REVOKE CREATETAB ON DATABASE FROM PUBLIC;
  482. */
  483.  
  484. {
  485.   sqlastrt(sqla_program_id,0L,&sqlca);
  486.   sqlacall((unsigned short)24,6,0,0,0L);
  487. if (sqlca.sqlcode < 0)
  488. {
  489.    sqlastop(0L);
  490.    goto exit_error;
  491. }
  492.  
  493.   sqlastop(0L);
  494. }
  495.  
  496.  
  497.    
  498. /*
  499. EXEC SQL
  500.       REVOKE BINDADD ON DATABASE FROM PUBLIC;
  501. */
  502.  
  503. {
  504.   sqlastrt(sqla_program_id,0L,&sqlca);
  505.   sqlacall((unsigned short)24,7,0,0,0L);
  506. if (sqlca.sqlcode < 0)
  507. {
  508.    sqlastop(0L);
  509.    goto exit_error;
  510. }
  511.  
  512.   sqlastop(0L);
  513. }
  514.  
  515.  
  516.    
  517. /*
  518. EXEC SQL
  519.       REVOKE CONNECT ON DATABASE FROM PUBLIC;
  520. */
  521.  
  522. {
  523.   sqlastrt(sqla_program_id,0L,&sqlca);
  524.   sqlacall((unsigned short)24,8,0,0,0L);
  525. if (sqlca.sqlcode < 0)
  526. {
  527.    sqlastop(0L);
  528.    goto exit_error;
  529. }
  530.  
  531.   sqlastop(0L);
  532. }
  533.  
  534.  
  535.    strcpy(rte_label,"GRANT PRIVILEGE");
  536.  
  537.    
  538. /*
  539. EXEC SQL
  540.       GRANT DBADM ON DATABASE TO GDBADM, BADMIN;
  541. */
  542.  
  543. {
  544.   sqlastrt(sqla_program_id,0L,&sqlca);
  545.   sqlacall((unsigned short)24,9,0,0,0L);
  546. if (sqlca.sqlcode < 0)
  547. {
  548.    sqlastop(0L);
  549.    goto exit_error;
  550. }
  551.  
  552.   sqlastop(0L);
  553. }
  554.  
  555.  
  556.    
  557. /*
  558. EXEC SQL
  559.       GRANT CONNECT, BINDADD ON DATABASE TO GPREP, PREP;
  560. */
  561.  
  562. {
  563.   sqlastrt(sqla_program_id,0L,&sqlca);
  564.   sqlacall((unsigned short)24,10,0,0,0L);
  565. if (sqlca.sqlcode < 0)
  566. {
  567.    sqlastop(0L);
  568.    goto exit_error;
  569. }
  570.  
  571.   sqlastop(0L);
  572. }
  573.  
  574.  
  575.    
  576. /*
  577. EXEC SQL
  578.       GRANT CONNECT, CREATETAB ON DATABASE TO GCREATE, TCREATE;
  579. */
  580.  
  581. {
  582.   sqlastrt(sqla_program_id,0L,&sqlca);
  583.   sqlacall((unsigned short)24,11,0,0,0L);
  584. if (sqlca.sqlcode < 0)
  585. {
  586.    sqlastop(0L);
  587.    goto exit_error;
  588. }
  589.  
  590.   sqlastop(0L);
  591. }
  592.  
  593.  
  594.  
  595.    
  596. /*
  597. EXEC SQL
  598.       GRANT CONNECT ON DATABASE TO GQRYSEL, QRYSEL, GEDIT, TEDIT, GTVCON,
  599.       TVCON, GSELINS, SELINS, REFER, TDELETE, TUPDATE, SELUPDEL, TEXECUTE,
  600.       EDITALT;
  601. */
  602.  
  603. {
  604.   sqlastrt(sqla_program_id,0L,&sqlca);
  605.   sqlacall((unsigned short)24,12,0,0,0L);
  606. if (sqlca.sqlcode < 0)
  607. {
  608.    sqlastop(0L);
  609.    goto exit_error;
  610. }
  611.  
  612.   sqlastop(0L);
  613. }
  614.  
  615.  
  616.    
  617. /*
  618. EXEC SQL
  619.       GRANT SELECT ON TABLE CUSTOMER TO GQRYSEL, QRYSEL;
  620. */
  621.  
  622. {
  623.   sqlastrt(sqla_program_id,0L,&sqlca);
  624.   sqlacall((unsigned short)24,13,0,0,0L);
  625. if (sqlca.sqlcode < 0)
  626. {
  627.    sqlastop(0L);
  628.    goto exit_error;
  629. }
  630.  
  631.   sqlastop(0L);
  632. }
  633.  
  634.  
  635.    
  636. /*
  637. EXEC SQL
  638.       GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE CUSTOMER TO GEDIT, TEDIT;
  639. */
  640.  
  641. {
  642.   sqlastrt(sqla_program_id,0L,&sqlca);
  643.   sqlacall((unsigned short)24,14,0,0,0L);
  644. if (sqlca.sqlcode < 0)
  645. {
  646.    sqlastop(0L);
  647.    goto exit_error;
  648. }
  649.  
  650.   sqlastop(0L);
  651. }
  652.  
  653.  
  654.    
  655. /*
  656. EXEC SQL
  657.       GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE CHECKING TO GEDIT, TEDIT;
  658. */
  659.  
  660. {
  661.   sqlastrt(sqla_program_id,0L,&sqlca);
  662.   sqlacall((unsigned short)24,15,0,0,0L);
  663. if (sqlca.sqlcode < 0)
  664. {
  665.    sqlastop(0L);
  666.    goto exit_error;
  667. }
  668.  
  669.   sqlastop(0L);
  670. }
  671.  
  672.  
  673.    
  674. /*
  675. EXEC SQL
  676.       GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE SAVINGS TO GEDIT, TEDIT;
  677. */
  678.  
  679. {
  680.   sqlastrt(sqla_program_id,0L,&sqlca);
  681.   sqlacall((unsigned short)24,16,0,0,0L);
  682. if (sqlca.sqlcode < 0)
  683. {
  684.    sqlastop(0L);
  685.    goto exit_error;
  686. }
  687.  
  688.   sqlastop(0L);
  689. }
  690.  
  691.  
  692.    
  693. /*
  694. EXEC SQL COMMIT;
  695. */
  696.  
  697. {
  698.   sqlastrt(sqla_program_id,0L,&sqlca);
  699.   sqlacall((unsigned short)21,0,0,0,0L);
  700. if (sqlca.sqlcode < 0)
  701. {
  702.    sqlastop(0L);
  703.    goto exit_error;
  704. }
  705.  
  706.   sqlastop(0L);
  707. }
  708.  
  709. /*****************************************************************************/
  710. /*      Create View 1   -   for D30ACB02  (year end loan report)             */
  711. /*****************************************************************************/
  712.  
  713.      strcpy (rte_label,"create vloan   ");
  714.  
  715.      
  716. /*
  717. EXEC SQL
  718.           CREATE VIEW VLOAN AS
  719.  
  720.           SELECT CU_SSN,CU_NAME,CU_ADDR1,CU_ADDR2,CU_ZIP,L_NUMB,L_TYPE,L_RATE,
  721.                  L_PAYMT,L_BAL,L_INTODAT,L_DESCRIP,L_DATE,L_SSN,L_TERM
  722.  
  723.           FROM   CUSTOMER, LOAN
  724.  
  725.           WHERE  CUSTOMER.CU_SSN = LOAN.L_SSN;
  726. */
  727.  
  728. {
  729.   sqlastrt(sqla_program_id,0L,&sqlca);
  730.   sqlacall((unsigned short)24,17,0,0,0L);
  731. if (sqlca.sqlcode < 0)
  732. {
  733.    sqlastop(0L);
  734.    goto exit_error;
  735. }
  736.  
  737.   sqlastop(0L);
  738. }
  739.  
  740.  
  741. /*****************************************************************************/
  742. /*      Create View 2   -   for D30ACB02  (savings report)                   */
  743. /*****************************************************************************/
  744.  
  745.      strcpy (rte_label,"create vsave   ");
  746.  
  747.      
  748. /*
  749. EXEC SQL
  750.           CREATE VIEW VSAVE AS
  751.  
  752.           SELECT CU_SSN,CU_NAME,S_INTTOD,S_ACCNUMB,S_BAL,S_SSN
  753.  
  754.           FROM   CUSTOMER, SAVINGS
  755.  
  756.           WHERE  CUSTOMER.CU_SSN = SAVINGS.S_SSN;
  757. */
  758.  
  759. {
  760.   sqlastrt(sqla_program_id,0L,&sqlca);
  761.   sqlacall((unsigned short)24,18,0,0,0L);
  762. if (sqlca.sqlcode < 0)
  763. {
  764.    sqlastop(0L);
  765.    goto exit_error;
  766. }
  767.  
  768.   sqlastop(0L);
  769. }
  770.  
  771.  
  772.  
  773.      
  774. /*
  775. EXEC SQL  COMMIT;
  776. */
  777.  
  778. {
  779.   sqlastrt(sqla_program_id,0L,&sqlca);
  780.   sqlacall((unsigned short)21,0,0,0,0L);
  781. if (sqlca.sqlcode < 0)
  782. {
  783.    sqlastop(0L);
  784.    goto exit_error;
  785. }
  786.  
  787.   sqlastop(0L);
  788. }
  789.  
  790.  
  791.  
  792. /********************************************     ***************/
  793. /*      Create View 3   -   for D30ACB06  (view import)                      */
  794. /*****************************************************************************/
  795.  
  796.      strcpy (rte_label,"create viewbox ");
  797.  
  798.      
  799. /*
  800. EXEC SQL
  801.           CREATE VIEW VIEWBOX AS
  802.  
  803.           SELECT B_NUMB, B_SIZE, B_RENT
  804.  
  805.           FROM   BOX
  806.  
  807.           WHERE  B_SIZE = 'M';
  808. */
  809.  
  810. {
  811.   sqlastrt(sqla_program_id,0L,&sqlca);
  812.   sqlacall((unsigned short)24,19,0,0,0L);
  813. if (sqlca.sqlcode < 0)
  814. {
  815.    sqlastop(0L);
  816.    goto exit_error;
  817. }
  818.  
  819.   sqlastop(0L);
  820. }
  821.  
  822.  
  823.  
  824.      
  825. /*
  826. EXEC SQL  COMMIT;
  827. */
  828.  
  829. {
  830.   sqlastrt(sqla_program_id,0L,&sqlca);
  831.   sqlacall((unsigned short)21,0,0,0,0L);
  832. if (sqlca.sqlcode < 0)
  833. {
  834.    sqlastop(0L);
  835.    goto exit_error;
  836. }
  837.  
  838.   sqlastop(0L);
  839. }
  840.  
  841. /*****************************************************************************/
  842. /*      Create View 4   -   for D30ACB06  (view import)                      */
  843. /*****************************************************************************/
  844.  
  845.      strcpy (rte_label,"create viewcust");
  846.  
  847.      
  848. /*
  849. EXEC SQL
  850.           CREATE VIEW VIEWCUST AS
  851.  
  852.           SELECT *
  853.  
  854.           FROM   NEWCUST;
  855. */
  856.  
  857. {
  858.   sqlastrt(sqla_program_id,0L,&sqlca);
  859.   sqlacall((unsigned short)24,20,0,0,0L);
  860. if (sqlca.sqlcode < 0)
  861. {
  862.    sqlastop(0L);
  863.    goto exit_error;
  864. }
  865.  
  866.   sqlastop(0L);
  867. }
  868.  
  869.  
  870.      
  871. /*
  872. EXEC SQL  COMMIT;
  873. */
  874.  
  875. {
  876.   sqlastrt(sqla_program_id,0L,&sqlca);
  877.   sqlacall((unsigned short)21,0,0,0,0L);
  878. if (sqlca.sqlcode < 0)
  879. {
  880.    sqlastop(0L);
  881.    goto exit_error;
  882. }
  883.  
  884.   sqlastop(0L);
  885. }
  886.  
  887.  
  888. /*****************************************************************************/
  889. /*      Create View 5   -   for D30ACB05  (view export)                      */
  890. /*****************************************************************************/
  891.  
  892.      strcpy (rte_label,"create solloan ");
  893.  
  894.      
  895. /*
  896. EXEC SQL
  897.           CREATE VIEW SOLLOAN (SSN, SSNSC) AS
  898.  
  899.           ((SELECT CU_SSN, S_SSN
  900.             FROM CUSTOMER, SAVINGS
  901.             WHERE (CU_SSN = S_SSN) AND (S_BAL > 1000.00))
  902.  
  903.                       INTERSECT
  904.  
  905.            (SELECT CU_SSN, C_SSN1
  906.             FROM CUSTOMER, CHECKING
  907.             WHERE (CU_SSN = C_SSN1) AND (C_ENDBAL > 1000.00))
  908.  
  909.                       EXCEPT
  910.  
  911.            (SELECT CU_SSN, L_SSN
  912.             FROM CUSTOMER, LOAN
  913.             WHERE CU_SSN = L_SSN));
  914. */
  915.  
  916. {
  917.   sqlastrt(sqla_program_id,0L,&sqlca);
  918.   sqlacall((unsigned short)24,21,0,0,0L);
  919. if (sqlca.sqlcode < 0)
  920. {
  921.    sqlastop(0L);
  922.    goto exit_error;
  923. }
  924.  
  925.   sqlastop(0L);
  926. }
  927.  
  928.  
  929.        
  930. /*
  931. EXEC SQL COMMIT;
  932. */
  933.  
  934. {
  935.   sqlastrt(sqla_program_id,0L,&sqlca);
  936.   sqlacall((unsigned short)21,0,0,0,0L);
  937. if (sqlca.sqlcode < 0)
  938. {
  939.    sqlastop(0L);
  940.    goto exit_error;
  941. }
  942.  
  943.   sqlastop(0L);
  944. }
  945.  
  946.  
  947.  
  948. /*****************************************************************************/
  949. /*      Create View 6   -   for D30ACB05  (view export)                      */
  950. /*****************************************************************************/
  951.  
  952.      strcpy (rte_label,"create chkact  ");
  953.  
  954.      
  955. /*
  956. EXEC SQL
  957.      CREATE VIEW CHKACT (ACCNUMB) AS
  958.        ((SELECT C_ACCNUMB
  959.          FROM CHECKING
  960.          WHERE C_ACCNUMB NOT IN (SELECT DB_ACCNUMB FROM DEBITS))
  961.  
  962.                  INTERSECT
  963.  
  964.         (SELECT C_ACCNUMB
  965.          FROM CHECKING
  966.          WHERE C_ACCNUMB NOT IN (SELECT CR_ACCNUMB FROM CREDITS)));
  967. */
  968.  
  969. {
  970.   sqlastrt(sqla_program_id,0L,&sqlca);
  971.   sqlacall((unsigned short)24,22,0,0,0L);
  972. if (sqlca.sqlcode < 0)
  973. {
  974.    sqlastop(0L);
  975.    goto exit_error;
  976. }
  977.  
  978.   sqlastop(0L);
  979. }
  980.  
  981.  
  982.       
  983. /*
  984. EXEC SQL COMMIT;
  985. */
  986.  
  987. {
  988.   sqlastrt(sqla_program_id,0L,&sqlca);
  989.   sqlacall((unsigned short)21,0,0,0,0L);
  990. if (sqlca.sqlcode < 0)
  991. {
  992.    sqlastop(0L);
  993.    goto exit_error;
  994. }
  995.  
  996.   sqlastop(0L);
  997. }
  998.  
  999.  
  1000.  
  1001. /*****************************************************************************/
  1002. /*      Create View 7   -   for D30ACB05  (view export)                      */
  1003. /*****************************************************************************/
  1004.  
  1005.      strcpy (rte_label,"create inactcus");
  1006.  
  1007.      
  1008. /*
  1009. EXEC SQL
  1010.         CREATE VIEW INACTCUS (SSN) AS
  1011.          (SELECT CU_SSN FROM CUSTOMER
  1012.           WHERE CU_SSN NOT IN ((SELECT C_SSN1 FROM CHECKING)
  1013.                                         UNION
  1014.                               (SELECT S_SSN FROM SAVINGS)
  1015.                                         UNION
  1016.                               (SELECT L_SSN FROM LOAN)
  1017.                                         UNION
  1018.                               (SELECT B_SSN FROM BOX)));
  1019. */
  1020.  
  1021. {
  1022.   sqlastrt(sqla_program_id,0L,&sqlca);
  1023.   sqlacall((unsigned short)24,23,0,0,0L);
  1024. if (sqlca.sqlcode < 0)
  1025. {
  1026.    sqlastop(0L);
  1027.    goto exit_error;
  1028. }
  1029.  
  1030.   sqlastop(0L);
  1031. }
  1032.  
  1033.  
  1034.     
  1035. /*
  1036. EXEC SQL COMMIT;
  1037. */
  1038.  
  1039. {
  1040.   sqlastrt(sqla_program_id,0L,&sqlca);
  1041.   sqlacall((unsigned short)21,0,0,0,0L);
  1042. if (sqlca.sqlcode < 0)
  1043. {
  1044.    sqlastop(0L);
  1045.    goto exit_error;
  1046. }
  1047.  
  1048.   sqlastop(0L);
  1049. }
  1050.  
  1051.  
  1052. /****************************************     *******************/
  1053.  
  1054. /* Customer table import */
  1055.  
  1056.    strcpy (rte_label,"import customer");
  1057.  
  1058.         tcolstrg->length = 20;
  1059.         memcpy(tcolstrg->data,ins_cust,20);      /* default the tcolumn list */
  1060.  
  1061.         sqluimp (database,imp_cust,dcoldata,tcolstrg,
  1062.                  imptype,filetmod,custerr,callerac,&sqlca);
  1063.  
  1064.         if (sqlca.sqlcode < 0)
  1065.          {
  1066.           goto exit_error;
  1067.          }
  1068.  
  1069.    
  1070. /*
  1071. EXEC SQL COMMIT;
  1072. */
  1073.  
  1074. {
  1075.   sqlastrt(sqla_program_id,0L,&sqlca);
  1076.   sqlacall((unsigned short)21,0,0,0,0L);
  1077. if (sqlca.sqlcode < 0)
  1078. {
  1079.    sqlastop(0L);
  1080.    goto exit_error;
  1081. }
  1082.  
  1083.   sqlastop(0L);
  1084. }
  1085.  
  1086.  
  1087. /* Box table import */
  1088.  
  1089.    strcpy (rte_label,"import box data");
  1090.  
  1091.         memcpy(tcolstrg->data,ins_box,20);       /* default the tcolumn list */
  1092.  
  1093.         sqluimp (database,imp_box,dcoldata,tcolstrg,
  1094.                  imptype,filetmod,boxerr,callerac,&sqlca);
  1095.  
  1096.         if (sqlca.sqlcode < 0)
  1097.          {
  1098.           goto exit_error;
  1099.          }
  1100.  
  1101.     
  1102. /*
  1103. EXEC SQL COMMIT;
  1104. */
  1105.  
  1106. {
  1107.   sqlastrt(sqla_program_id,0L,&sqlca);
  1108.   sqlacall((unsigned short)21,0,0,0,0L);
  1109. if (sqlca.sqlcode < 0)
  1110. {
  1111.    sqlastop(0L);
  1112.    goto exit_error;
  1113. }
  1114.  
  1115.   sqlastop(0L);
  1116. }
  1117.  
  1118.  
  1119. /* Loan table import */
  1120.  
  1121.    strcpy (rte_label,"import loan dat");
  1122.  
  1123.         memcpy(tcolstrg->data,ins_loan,20);  /* default the tcolumn list     */
  1124.  
  1125.         sqluimp (database,imp_loan,dcoldata,tcolstrg,
  1126.                  imptype,filetmod,loanerr,callerac,&sqlca);
  1127.  
  1128.         if (sqlca.sqlcode < 0)
  1129.          {
  1130.           goto exit_error;
  1131.          }
  1132.  
  1133.      
  1134. /*
  1135. EXEC SQL COMMIT;
  1136. */
  1137.  
  1138. {
  1139.   sqlastrt(sqla_program_id,0L,&sqlca);
  1140.   sqlacall((unsigned short)21,0,0,0,0L);
  1141. if (sqlca.sqlcode < 0)
  1142. {
  1143.    sqlastop(0L);
  1144.    goto exit_error;
  1145. }
  1146.  
  1147.   sqlastop(0L);
  1148. }
  1149.  
  1150.  
  1151.  
  1152. /********************************************     ***************/
  1153.  
  1154.  
  1155. /* Savings table import */
  1156.  
  1157.    strcpy (rte_label,"import savings ");
  1158.  
  1159.         memcpy(tcolstrg->data,ins_sav,20);    /* default the tcolumn list    */
  1160.  
  1161.         sqluimp (database,imp_sav,dcoldata,tcolstrg,
  1162.                  imptype,filetmod,saverr,callerac,&sqlca);
  1163.  
  1164.         if (sqlca.sqlcode < 0)
  1165.          {
  1166.           goto exit_error;
  1167.          }
  1168.  
  1169.     
  1170. /*
  1171. EXEC SQL COMMIT;
  1172. */
  1173.  
  1174. {
  1175.   sqlastrt(sqla_program_id,0L,&sqlca);
  1176.   sqlacall((unsigned short)21,0,0,0,0L);
  1177. if (sqlca.sqlcode < 0)
  1178. {
  1179.    sqlastop(0L);
  1180.    goto exit_error;
  1181. }
  1182.  
  1183.   sqlastop(0L);
  1184. }
  1185.  
  1186.  
  1187. /* Checking table import */
  1188.  
  1189.    strcpy (rte_label,"import checking");
  1190.  
  1191.         memcpy(tcolstrg->data,ins_chck,20);    /* default the tcolumn list   */
  1192.  
  1193.         sqluimp (database,imp_chck,dcoldata,tcolstrg,
  1194.                  imptype,filetmod,chckerr,callerac,&sqlca);
  1195.  
  1196.  
  1197.  
  1198.    printf("\n inserting data into table PERFDAT3 \n");
  1199.    
  1200. /*
  1201. EXEC SQL
  1202. INSERT INTO  PERFDAT3 SELECT
  1203. CU_SSN , CU_NAME, CU_ADDR1 , CU_ADDR2 ,CU_ZIP , L_NUMB , L_TYPE, L_RATE ,
  1204. L_TERM ,L_PAYMT, L_BAL, L_INTODAT,L_DESCRIP, L_DATE, S_ACCNUMB , S_IRATE,
  1205. S_INTTOD, S_BAL, B_NUMB , B_SIZE,B_RENT ,  B_PAYUP, C_ACCNUMB , C_STARTBAL, C_ENDBAL
  1206. FROM CUSTOMER, LOAN, SAVINGS, BOX, CHECKING
  1207. WHERE CU_SSN = L_SSN AND CU_SSN = S_SSN AND CU_SSN = B_SSN AND CU_SSN = C_SSN1;
  1208. */
  1209.  
  1210. {
  1211.   sqlastrt(sqla_program_id,0L,&sqlca);
  1212.   sqlacall((unsigned short)24,24,0,0,0L);
  1213. if (sqlca.sqlcode < 0)
  1214. {
  1215.    sqlastop(0L);
  1216.    goto exit_error;
  1217. }
  1218.  
  1219.   sqlastop(0L);
  1220. }
  1221.  
  1222.  
  1223.    printf("\n inserting data into table PERFDAt4 \n");
  1224.    
  1225. /*
  1226. EXEC SQL
  1227. INSERT INTO  PERFDAt4 SELECT
  1228. CU_SSN , CU_NAME, CU_ADDR1 , CU_ADDR2 ,CU_ZIP , L_NUMB , L_TYPE, L_RATE ,
  1229. L_TERM ,L_PAYMT, L_BAL, L_INTODAT,L_DESCRIP, L_DATE, S_ACCNUMB , S_IRATE,
  1230. S_INTTOD, S_BAL, B_NUMB , B_SIZE,B_RENT ,  B_PAYUP, C_ACCNUMB , C_STARTBAL, C_ENDBAL
  1231. FROM CUSTOMER, LOAN, SAVINGS, BOX, CHECKING
  1232. WHERE CU_SSN = L_SSN AND CU_SSN = S_SSN AND CU_SSN = B_SSN AND CU_SSN = C_SSN1;
  1233. */
  1234.  
  1235. {
  1236.   sqlastrt(sqla_program_id,0L,&sqlca);
  1237.   sqlacall((unsigned short)24,25,0,0,0L);
  1238. if (sqlca.sqlcode < 0)
  1239. {
  1240.    sqlastop(0L);
  1241.    goto exit_error;
  1242. }
  1243.  
  1244.   sqlastop(0L);
  1245. }
  1246.  
  1247.  
  1248.  
  1249. /*
  1250. EXEC SQL CREATE INDEX  D3INDEX ON PERFDAT3  (CU_SSN ASC);
  1251. */
  1252.  
  1253. {
  1254.   sqlastrt(sqla_program_id,0L,&sqlca);
  1255.   sqlacall((unsigned short)24,26,0,0,0L);
  1256. if (sqlca.sqlcode < 0)
  1257. {
  1258.    sqlastop(0L);
  1259.    goto exit_error;
  1260. }
  1261.  
  1262.   sqlastop(0L);
  1263. }
  1264.  
  1265.  
  1266.  
  1267.         if (sqlca.sqlcode >= 0)
  1268.         {
  1269.              goto exit_normal;            /* exit the program due to error   */
  1270.         }
  1271.  
  1272.    
  1273. /*
  1274. EXEC SQL COMMIT;
  1275. */
  1276.  
  1277. {
  1278.   sqlastrt(sqla_program_id,0L,&sqlca);
  1279.   sqlacall((unsigned short)21,0,0,0,0L);
  1280. if (sqlca.sqlcode < 0)
  1281. {
  1282.    sqlastop(0L);
  1283.    goto exit_error;
  1284. }
  1285.  
  1286.   sqlastop(0L);
  1287. }
  1288.  
  1289.  
  1290.  
  1291. /********************************************     ***************/
  1292. /*****************************************************************************/
  1293. exit_error:
  1294.                                             /* set up error file processing  */
  1295.     errlevel = 2;                              /* set DOS return code -error */
  1296.  
  1297.     if ((ptr_errorfle = fopen(errorfle, "w")) == NULL)
  1298.  
  1299.      {
  1300.       printf ("\nUNABLE TO OPEN D30ACBC1.ERR\n");     /* can't open errorfle */
  1301.       printf ("%s\n",rte_label);                      /* display msg - screen*/
  1302.       printf ("SQLCODE IS %ld\n",sqlca.sqlcode);
  1303.       goto continue_err;
  1304.      }                                                /* print to error file */
  1305.  
  1306.     fprintf (ptr_errorfle,"%s\n%s\n",tcaseid,descript);
  1307.     fprintf (ptr_errorfle,"%s\n",rte_label);
  1308.     fprintf (ptr_errorfle,"SQLCODE IS %ld\n",sqlca.sqlcode);
  1309.  
  1310.                                               /* SQL miscellaneous error info*/
  1311.  
  1312.     fprintf(ptr_errorfle,"\nSQLERRD[0] is %ld",sqlca.sqlerrd[0]);
  1313.     fprintf(ptr_errorfle,"\nSQLERRD[1] is %ld",sqlca.sqlerrd[1]);
  1314.     fprintf(ptr_errorfle,"\nSQLERRD[2] is %ld",sqlca.sqlerrd[2]);
  1315.     fprintf(ptr_errorfle,"\nSQLERRD[3] is %ld",sqlca.sqlerrd[3]);
  1316.     fprintf(ptr_errorfle,"\nSQLERRD[4] is %ld",sqlca.sqlerrd[4]);
  1317.     fprintf(ptr_errorfle,"\nSQLERRD[5] is %ld",sqlca.sqlerrd[5]);
  1318.  
  1319.     memcpy (sqlerrp_value, sqlca.sqlerrp,8);
  1320.     fprintf(ptr_errorfle,"\nSQLERRP is %s",sqlerrp_value);
  1321.  
  1322.     rc = sqlaintp(msgbuf,512,0,&sqlca);
  1323.  
  1324.     if (rc < 0)                                      /* message retrieval err*/
  1325.  
  1326.     {
  1327.       fprintf (ptr_errorfle, "SQLAINTP ERROR.  Return Code = %d",rc);
  1328.     }
  1329.  
  1330.     else if (rc > 0)
  1331.      {                                              /* print error message   */
  1332.       fprintf (ptr_errorfle,"\n");
  1333.       fprintf (ptr_errorfle,msgbuf);
  1334.      }
  1335.     fclose(ptr_errorfle);                           /* close the error file  */
  1336.  
  1337.  
  1338. continue_err:                                  /* reset sqlerror to eliminate*/
  1339.                                                /*  looping if Rollback fails */
  1340.     
  1341. /*
  1342. EXEC SQL
  1343.             WHENEVER SQLERROR CONTINUE;
  1344. */
  1345.  
  1346.  
  1347.     
  1348. /*
  1349. EXEC SQL
  1350.             ROLLBACK WORK;
  1351. */
  1352.  
  1353. {
  1354.   sqlastrt(sqla_program_id,0L,&sqlca);
  1355.   sqlacall((unsigned short)28,0,0,0,0L);
  1356.   sqlastop(0L);
  1357. }
  1358.                      /* Rollback any work          */
  1359.  
  1360.     if (sqlca.sqlcode < 0)                     /* Rollback failed            */
  1361.      {
  1362.       if ((ptr_errorfle = fopen(errorfle,"a")) == NULL)  /* open errorfle    */
  1363.  
  1364.        {                                       /* open failed - display msg. */
  1365.         printf ("\nUNABLE TO OPEN D30ACBC1.ERR -- ROLLBACK FAILED");
  1366.         goto exit_normal;
  1367.        }
  1368.  
  1369.    fprintf (ptr_errorfle,"\nSQLCODE IS %ld,  ROLLBACK FAILED.",sqlca.sqlcode);
  1370.  
  1371.       fclose(ptr_errorfle);                    /* close the error file       */
  1372.      }
  1373.  
  1374. /*****************************************************************************/
  1375.  
  1376. /********************************************     ***************/
  1377. exit_normal:
  1378.  
  1379.    if (dbas_cls == 0)
  1380.     {
  1381.      sqlestpd (&sqlca);                   /* stop using the database         */
  1382.     }
  1383.  
  1384.    return(errlevel);                      /* DOS error return code           */
  1385.  }
  1386.