home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / DBDEMO.ZIP / DEMODB.ZIP / D30ACBB1.C < prev    next >
Text File  |  1991-07-03  |  42KB  |  1,730 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,66,49,80,65,99,71,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:  D30ACBB1.SQC of D30ACB01                    */
  52. /*                                                                         */
  53. /*  PROGRAM LANGUAGE: 'C' Language                                         */
  54. /*                                                                         */
  55. /*  PROGRAM DESCRIPTION:  D30ACBB1.SQC is the second program of the        */
  56. /*                        D30ACB01 creation application.                   */
  57. /*                                                                         */
  58. /*                        This program will create the 7 tables of the     */
  59. /*                        BANK data base:                                  */
  60. /*                                                                         */
  61. /*                              Customer                                   */
  62. /*                              Box                                        */
  63. /*                              Checking                                   */
  64. /*                              Credits                                    */
  65. /*                              Debits                                     */
  66. /*                              Loan                                       */
  67. /*                              Savings                                    */
  68. /*                                                                         */
  69. /*                        An additional table will also be created that    */
  70. /*                        will be identical to the Customer table.  This   */
  71. /*                        table will be used with the import through a     */
  72. /*                        view (Replace option) test.  It will be named:   */
  73. /*                                                                         */
  74. /*                              Newcust                                    */
  75. /*                                                                         */
  76. /*  AUTHOR:   D. J. Grant                    DATE: 04/22/87                */
  77. /*                                                                         */
  78. /*  DATABASE:  Gemstone BANK database                                      */
  79. /*                                                                         */
  80. /*  INPUT FILES:  None                                                     */
  81. /*                                                                         */
  82. /*  OUTPUT FILES:                                                          */
  83. /*                                                                         */
  84. /*            D30ACBB1.ERR - this is a file, written to disk, only         */
  85. /*            when some type of error condition is returned from           */
  86. /*            SQL.  It serves as an error log, recording the error         */
  87. /*            code, its corresponding error message, and any other         */
  88. /*            useful information which the program might be able           */
  89. /*            to give.                                                     */
  90. /*                                                                         */
  91. /*  DEPENDENCIES:                                                          */
  92. /*                                                                         */
  93. /*            GEORGETOWN, Gemstone DIAMOND data base kernel,               */
  94. /*            creation of Gemstone BANK data base,                         */
  95. /*            pre-compilation with Gemstone SQLPREP,                       */
  96. /*            binding to data base with SQLPREP or SQLBIND,                */
  97. /*            compilation with IBM C/2, using compiler options:            */
  98. /*                     "/AL /Gs /DLINT_ARGS /DSQL_REL_10 /W3 /Od /FPa"     */
  99. /*                                                                         */
  100. /***  Prologue continued on next page  *************************************/
  101.  
  102.  
  103.  
  104.  
  105. /******************************************       *************/
  106. /*                                                                         */
  107. /*  FUNCTION CALLS:                                                        */
  108. /*                                                                         */
  109. /*            COMPILER LIBRARY                                             */
  110. /*                 stdio.h - fopen,fclose,fprintf,printf                   */
  111. /*                 string.h - strcpy                                       */
  112. /*                                                                         */
  113. /*            GEMSTONE LIBRARY                                             */
  114. /*                 sql.h    - sqlaintp                                     */
  115. /*                 sqlenv.h - sqlestrd,sqlestpd                            */
  116. /*                          - sqleisig (ctrl-break processing)             */
  117. /*                 sqlca.h  - sqlca.sqlcode                                */
  118. /*                                                                         */
  119. /*            OTHER                                                        */
  120. /*                 none                                                    */
  121. /*                                                                         */
  122. /*  ERROR CONDITIONS:                                                      */
  123. /*                                                                         */
  124. /*            NORMAL - specifically tested for and handled by the ap-      */
  125. /*                     application program:  (exit_normal)                 */
  126. /*                   - DOS return code = 0.  (errorlvl)                    */
  127. /*                                                                         */
  128. /*                                                                         */
  129. /*            ABNORMAL - unexpected and resulting in program termination:  */
  130. /*                       (exit_error)                                      */
  131. /*                     - 1015 : start database failed, restart database    */
  132. /*                     - DOS return code = 2.   (errorlvl)                 */
  133. /*                                                                         */
  134. /*  MODIFICATIONS:                                                         */
  135. /*                                                                         */
  136. /*            Date      Author         Description                         */
  137. /*                                                                         */
  138. /*           09/15/87   D. J. Grant    - Update prologue.                  */
  139. /*                                     - Put     on every     */
  140. /*                                         page.                           */
  141. /*                                     - Add code to pass return codes to  */
  142. /*                                         DOS.                            */
  143. /*                                     - Add code to enhance exit_error.   */
  144. /*                                     - Made references to sqlca lower    */
  145. /*                                         case.                           */
  146. /*                                                                         */
  147. /*           10/05/87   D. J. Grant    - change L_DATE type in LOAN table. */
  148. /*                                     - change rc compare in exit_error   */
  149. /*                                         to rc > 0.                      */
  150. /*          10/26/87    D.J.Grant      Added SQLEISIG function call, and   */
  151. /*                                     enhances exit_error to also print   */
  152. /*                                     SQLERRD[0] - [5] and SQL_ERRP.      */
  153. /*           03/08/88    D.J.Grant     - took out some compiler options.   */
  154. /*                                     - add the create Newcust table and  */
  155. /*                                       updated the prologue accordingly. */
  156. /*           02/03/89    W.B.Brown     - upgraded for Rel 3.0              */
  157. /*******  End of prologue  *************************************************/
  158.  
  159. /*******************************         ************************/
  160. /*  SET UP INCLUDES                                                          */
  161. /*****************************************************************************/
  162. #include <stdio.h>
  163. #include <sql.h>
  164. #include <string.h>
  165. #include <sqlenv.h>
  166.  
  167.  
  168. /*
  169. EXEC SQL INCLUDE sqlca;
  170. */
  171.  
  172. /* SQL Communication Area - SQLCA - structures and constants */
  173.  
  174. #ifndef SQLCODE
  175.  
  176. /* SQL Communication Area - SQLCA */
  177. struct sqlca
  178. {
  179.    unsigned char  sqlcaid[8];           /* Eyecatcher = 'SQLCA   ' */
  180.    long           sqlcabc;              /* SQLCA size in bytes = 136 */
  181.    long           sqlcode;              /* SQL return code */
  182.    short          sqlerrml;             /* Length for SQLERRMC */
  183.    unsigned char  sqlerrmc[70];         /* Error message tokens */
  184.    unsigned char  sqlerrp[8];           /* Diagnostic information */
  185.    long           sqlerrd[6];           /* Diagnostic information */
  186.    unsigned char  sqlwarn[8];           /* Warning flags */
  187.    unsigned char  sqlext[8];            /* Reserved */
  188. };
  189.  
  190. #define   SQLCODE        sqlca.sqlcode
  191. #define   SQLWARN0       sqlca.sqlwarn[0]
  192. #define   SQLWARN1       sqlca.sqlwarn[1]
  193. #define   SQLWARN2       sqlca.sqlwarn[2]
  194. #define   SQLWARN3       sqlca.sqlwarn[3]
  195. #define   SQLWARN4       sqlca.sqlwarn[4]
  196. #define   SQLWARN5       sqlca.sqlwarn[5]
  197. #define   SQLWARN6       sqlca.sqlwarn[6]
  198. #define   SQLWARN7       sqlca.sqlwarn[7]
  199.  
  200. #endif
  201.  
  202. struct sqlca sqlca;
  203.  
  204.  
  205. /*****************************************************************************/
  206. /*  DEFINITIONS AND DECLARATIONS                                             */
  207. /*****************************************************************************/
  208.    unsigned char  sqlerrp_value[9] = "        ";        /* error value    */
  209. /*******************************/
  210. /* Set up error message buffer */
  211. /*******************************/
  212.  
  213.         unsigned char msgbuf[512];
  214.  
  215. /********************************************/
  216. /* Declarations for D30ACBB1.ERR error file */
  217. /********************************************/
  218.  
  219.         unsigned char  errorfle[]="D30ACBB1.ERR";
  220.  
  221.         unsigned char   tcaseid[]="Test Case Id : D30ACBB1.SQC";
  222.         unsigned char  descript[]="BANK:  base table creation";
  223.  
  224. /***********************************/
  225. /* Declarations for BANK data base */
  226. /***********************************/
  227.  
  228.         unsigned char  database[]="bank";  /* establish database name        */
  229.         unsigned char  password[]="";      /* set up null password           */
  230.  
  231. /***********************************************/
  232. /* Set up variable to pass return codes to DOS */
  233. /***********************************************/
  234.  
  235.         short errorlvl = 0;            /* variable used to pass return codes */
  236.                                        /*   to DOS                           */
  237. /*****************************************************************************/
  238. int  main (void);
  239.      main ()
  240. {
  241.  
  242. /* declare local program variables */
  243.  
  244.    unsigned char rte_label[16];             /* program progress marker       */
  245.    short rc = 0;                            /* variable for return code      */
  246.  
  247. /* declare output file */
  248.  
  249.    FILE *ptr_output;                        /* pointer to output file        */
  250.  
  251.  
  252. /***************************************       ******************/
  253. /*  ERROR HANDLING FOR SQL STATEMENTS                                        */
  254. /*****************************************************************************/
  255.  
  256.         
  257. /*
  258. EXEC SQL
  259.              WHENEVER SQLERROR GOTO stop_datab;
  260. */
  261.  
  262.         
  263. /*
  264. EXEC SQL
  265.              WHENEVER SQLWARNING CONTINUE;
  266. */
  267.  
  268.         
  269. /*
  270. EXEC SQL
  271.              WHENEVER NOT FOUND CONTINUE;
  272. */
  273.  
  274.  
  275. /*****************************************************************************/
  276.  
  277.   strcpy(rte_label,"instal sqleisig");
  278.  
  279.   sqleisig(&sqlca);                             /* ctrl-break processing     */
  280.  
  281.   if (sqlca.sqlcode != 0)
  282.     {
  283.      goto exit_error;
  284.     }
  285.  
  286. /***************************************************************************/
  287. /*****************************************************************************/
  288. /*  START USING DATABASE                                                     */
  289. /*****************************************************************************/
  290.  
  291.         strcpy(rte_label,"start database ");
  292.  
  293.         sqlestrd (database,'S',&sqlca);  /* no password, and shared */
  294.  
  295.         if (sqlca.sqlcode == -1015)
  296.         {
  297.          strcpy(rte_label,"restart databas");
  298.          sqlerest (database,&sqlca);     /* restart database if need*/
  299.          if (sqlca.sqlcode != 0)
  300.          {
  301.            goto exit_error;
  302.          }
  303.          strcpy(rte_label,"start dbase 2nd");
  304.          sqlestrd (database,'S',&sqlca);  /* second start attempt   */
  305.         }
  306.         if (sqlca.sqlcode != 0)
  307.         {
  308.              goto exit_error;             /* exit the program  on error      */
  309.          }
  310.  
  311.  
  312. /***************************************       ******************/
  313. /*****************************************************************************/
  314. /*      Create the CUSTOMER base table                                       */
  315. /*****************************************************************************/
  316.  
  317.      strcpy(rte_label,"create customer");
  318.  
  319.  
  320. /*
  321. EXEC SQL CREATE TABLE CUSTOMER
  322.    (CU_SSN    CHAR     (11)   NOT NULL PRIMARY KEY,
  323.     CU_NAME   CHAR     (30)   NOT NULL,
  324.     CU_ADDR1  CHAR     (25)   NOT NULL,
  325.     CU_ADDR2  CHAR     (25)   NOT NULL,
  326.     CU_ZIP    CHAR      (5)   NOT NULL);
  327. */
  328.  
  329. {
  330.   sqlastrt(sqla_program_id,0L,&sqlca);
  331.   sqlacall((unsigned short)24,1,0,0,0L);
  332. if (sqlca.sqlcode < 0)
  333. {
  334.    sqlastop(0L);
  335.    goto stop_datab;
  336. }
  337.  
  338.   sqlastop(0L);
  339. }
  340.  
  341.  
  342.  
  343.      strcpy(rte_label,"cust tbl commt ");  /* define table comment */
  344.  
  345.  
  346. /*
  347. EXEC SQL COMMENT ON TABLE CUSTOMER
  348.  
  349.          IS 'This is the customer table of the BANK data base';
  350. */
  351.  
  352. {
  353.   sqlastrt(sqla_program_id,0L,&sqlca);
  354.   sqlacall((unsigned short)24,2,0,0,0L);
  355. if (sqlca.sqlcode < 0)
  356. {
  357.    sqlastop(0L);
  358.    goto stop_datab;
  359. }
  360.  
  361.   sqlastop(0L);
  362. }
  363.  
  364.  
  365.  
  366.      strcpy(rte_label,"cust col commts");  /* define comments for columns */
  367.  
  368.  
  369. /*
  370. EXEC SQL COMMENT ON  COLUMN CUSTOMER.CU_SSN
  371.  
  372.          IS 'customer social security number: table key';
  373. */
  374.  
  375. {
  376.   sqlastrt(sqla_program_id,0L,&sqlca);
  377.   sqlacall((unsigned short)24,3,0,0,0L);
  378. if (sqlca.sqlcode < 0)
  379. {
  380.    sqlastop(0L);
  381.    goto stop_datab;
  382. }
  383.  
  384.   sqlastop(0L);
  385. }
  386.  
  387.  
  388.  
  389. /*
  390. EXEC SQL COMMENT ON  COLUMN CUSTOMER.CU_NAME
  391.  
  392.          IS 'customer name';
  393. */
  394.  
  395. {
  396.   sqlastrt(sqla_program_id,0L,&sqlca);
  397.   sqlacall((unsigned short)24,4,0,0,0L);
  398. if (sqlca.sqlcode < 0)
  399. {
  400.    sqlastop(0L);
  401.    goto stop_datab;
  402. }
  403.  
  404.   sqlastop(0L);
  405. }
  406.  
  407.  
  408.  
  409. /*
  410. EXEC SQL COMMENT ON  COLUMN CUSTOMER.CU_ADDR1
  411.  
  412.          IS 'street address';
  413. */
  414.  
  415. {
  416.   sqlastrt(sqla_program_id,0L,&sqlca);
  417.   sqlacall((unsigned short)24,5,0,0,0L);
  418. if (sqlca.sqlcode < 0)
  419. {
  420.    sqlastop(0L);
  421.    goto stop_datab;
  422. }
  423.  
  424.   sqlastop(0L);
  425. }
  426.  
  427.  
  428.  
  429. /*
  430. EXEC SQL COMMENT ON  COLUMN CUSTOMER.CU_ADDR2
  431.  
  432.          IS 'city / state';
  433. */
  434.  
  435. {
  436.   sqlastrt(sqla_program_id,0L,&sqlca);
  437.   sqlacall((unsigned short)24,6,0,0,0L);
  438. if (sqlca.sqlcode < 0)
  439. {
  440.    sqlastop(0L);
  441.    goto stop_datab;
  442. }
  443.  
  444.   sqlastop(0L);
  445. }
  446.  
  447.  
  448.  
  449. /*
  450. EXEC SQL COMMENT ON  COLUMN CUSTOMER.CU_ZIP
  451.  
  452.          IS 'zip code - no extensions allowed';
  453. */
  454.  
  455. {
  456.   sqlastrt(sqla_program_id,0L,&sqlca);
  457.   sqlacall((unsigned short)24,7,0,0,0L);
  458. if (sqlca.sqlcode < 0)
  459. {
  460.    sqlastop(0L);
  461.    goto stop_datab;
  462. }
  463.  
  464.   sqlastop(0L);
  465. }
  466.  
  467.  
  468.  
  469. /*****************************************************************************/
  470. /*      Create the NEWCUST view import table                                 */
  471. /*****************************************************************************/
  472.  
  473.      strcpy(rte_label,"create newcust ");
  474.  
  475.  
  476. /*
  477. EXEC SQL CREATE TABLE NEWCUST
  478.    (SSN    CHAR     (11)   NOT NULL,
  479.     NAME   CHAR     (30)   NOT NULL,
  480.     ADDR1  CHAR     (25)   NOT NULL,
  481.     ADDR2  CHAR     (25)   NOT NULL,
  482.     ZIP    CHAR      (5)   NOT NULL);
  483. */
  484.  
  485. {
  486.   sqlastrt(sqla_program_id,0L,&sqlca);
  487.   sqlacall((unsigned short)24,8,0,0,0L);
  488. if (sqlca.sqlcode < 0)
  489. {
  490.    sqlastop(0L);
  491.    goto stop_datab;
  492. }
  493.  
  494.   sqlastop(0L);
  495. }
  496.  
  497.  
  498.  
  499.      strcpy(rte_label,"newcust tbl cmt");  /* define table comment */
  500.  
  501.  
  502. /*
  503. EXEC SQL COMMENT ON TABLE NEWCUST
  504.  
  505.          IS 'This is the newcust  table of the BANK data base';
  506. */
  507.  
  508. {
  509.   sqlastrt(sqla_program_id,0L,&sqlca);
  510.   sqlacall((unsigned short)24,9,0,0,0L);
  511. if (sqlca.sqlcode < 0)
  512. {
  513.    sqlastop(0L);
  514.    goto stop_datab;
  515. }
  516.  
  517.   sqlastop(0L);
  518. }
  519.  
  520.  
  521.  
  522.      strcpy(rte_label,"newcust col cmt");  /* define comments for columns */
  523.  
  524.  
  525. /*
  526. EXEC SQL COMMENT ON  COLUMN NEWCUST.SSN
  527.  
  528.          IS 'newcust  social security number: table key';
  529. */
  530.  
  531. {
  532.   sqlastrt(sqla_program_id,0L,&sqlca);
  533.   sqlacall((unsigned short)24,10,0,0,0L);
  534. if (sqlca.sqlcode < 0)
  535. {
  536.    sqlastop(0L);
  537.    goto stop_datab;
  538. }
  539.  
  540.   sqlastop(0L);
  541. }
  542.  
  543.  
  544.  
  545. /*
  546. EXEC SQL COMMENT ON  COLUMN NEWCUST.NAME
  547.  
  548.          IS 'newcust  name';
  549. */
  550.  
  551. {
  552.   sqlastrt(sqla_program_id,0L,&sqlca);
  553.   sqlacall((unsigned short)24,11,0,0,0L);
  554. if (sqlca.sqlcode < 0)
  555. {
  556.    sqlastop(0L);
  557.    goto stop_datab;
  558. }
  559.  
  560.   sqlastop(0L);
  561. }
  562.  
  563.  
  564.  
  565. /*
  566. EXEC SQL COMMENT ON  COLUMN NEWCUST.ADDR1
  567.  
  568.          IS 'street address';
  569. */
  570.  
  571. {
  572.   sqlastrt(sqla_program_id,0L,&sqlca);
  573.   sqlacall((unsigned short)24,12,0,0,0L);
  574. if (sqlca.sqlcode < 0)
  575. {
  576.    sqlastop(0L);
  577.    goto stop_datab;
  578. }
  579.  
  580.   sqlastop(0L);
  581. }
  582.  
  583.  
  584.  
  585. /*
  586. EXEC SQL COMMENT ON  COLUMN NEWCUST.ADDR2
  587.  
  588.          IS 'city / state';
  589. */
  590.  
  591. {
  592.   sqlastrt(sqla_program_id,0L,&sqlca);
  593.   sqlacall((unsigned short)24,13,0,0,0L);
  594. if (sqlca.sqlcode < 0)
  595. {
  596.    sqlastop(0L);
  597.    goto stop_datab;
  598. }
  599.  
  600.   sqlastop(0L);
  601. }
  602.  
  603.  
  604.  
  605. /*
  606. EXEC SQL COMMENT ON  COLUMN NEWCUST.ZIP
  607.  
  608.          IS 'zip code - no extensions allowed';
  609. */
  610.  
  611. {
  612.   sqlastrt(sqla_program_id,0L,&sqlca);
  613.   sqlacall((unsigned short)24,14,0,0,0L);
  614. if (sqlca.sqlcode < 0)
  615. {
  616.    sqlastop(0L);
  617.    goto stop_datab;
  618. }
  619.  
  620.   sqlastop(0L);
  621. }
  622.  
  623.  
  624.  
  625. /***************************************       ******************/
  626. /*****************************************************************************/
  627. /*      Create the BOX base table                                            */
  628. /*****************************************************************************/
  629.  
  630.      strcpy(rte_label,"create box tbl ");
  631.  
  632.  
  633. /*
  634. EXEC SQL CREATE TABLE BOX
  635.  
  636.    (B_NUMB   CHAR      (3)   NOT NULL,
  637.     B_SIZE   CHAR      (1)   NOT NULL,
  638.     B_RENT   DECIMAL (3,2)   NOT NULL,
  639.     B_SSN    CHAR     (11)           ,
  640.     B_PAYUP  CHAR      (3)           );
  641. */
  642.  
  643. {
  644.   sqlastrt(sqla_program_id,0L,&sqlca);
  645.   sqlacall((unsigned short)24,15,0,0,0L);
  646. if (sqlca.sqlcode < 0)
  647. {
  648.    sqlastop(0L);
  649.    goto stop_datab;
  650. }
  651.  
  652.   sqlastop(0L);
  653. }
  654.  
  655.  
  656.      strcpy(rte_label,"box tbl comment");   /* define box table comment */
  657.  
  658.  
  659. /*
  660. EXEC SQL COMMENT ON TABLE BOX
  661.  
  662.          IS 'This is the box table of the BANK data base';
  663. */
  664.  
  665. {
  666.   sqlastrt(sqla_program_id,0L,&sqlca);
  667.   sqlacall((unsigned short)24,16,0,0,0L);
  668. if (sqlca.sqlcode < 0)
  669. {
  670.    sqlastop(0L);
  671.    goto stop_datab;
  672. }
  673.  
  674.   sqlastop(0L);
  675. }
  676.  
  677.  
  678.      strcpy(rte_label,"box col comment");   /* define box column comments */
  679.  
  680.  
  681. /*
  682. EXEC SQL COMMENT ON  COLUMN BOX.B_NUMB
  683.  
  684.          IS 'this is the safety deposit box number: table key';
  685. */
  686.  
  687. {
  688.   sqlastrt(sqla_program_id,0L,&sqlca);
  689.   sqlacall((unsigned short)24,17,0,0,0L);
  690. if (sqlca.sqlcode < 0)
  691. {
  692.    sqlastop(0L);
  693.    goto stop_datab;
  694. }
  695.  
  696.   sqlastop(0L);
  697. }
  698.  
  699.  
  700.  
  701. /*
  702. EXEC SQL COMMENT ON  COLUMN BOX.B_SIZE
  703.  
  704.          IS 'this is the size of the box: S, M, or L';
  705. */
  706.  
  707. {
  708.   sqlastrt(sqla_program_id,0L,&sqlca);
  709.   sqlacall((unsigned short)24,18,0,0,0L);
  710. if (sqlca.sqlcode < 0)
  711. {
  712.    sqlastop(0L);
  713.    goto stop_datab;
  714. }
  715.  
  716.   sqlastop(0L);
  717. }
  718.  
  719.  
  720.  
  721. /*
  722. EXEC SQL COMMENT ON  COLUMN BOX.B_RENT
  723.  
  724.          IS 'box rental amount per month';
  725. */
  726.  
  727. {
  728.   sqlastrt(sqla_program_id,0L,&sqlca);
  729.   sqlacall((unsigned short)24,19,0,0,0L);
  730. if (sqlca.sqlcode < 0)
  731. {
  732.    sqlastop(0L);
  733.    goto stop_datab;
  734. }
  735.  
  736.   sqlastop(0L);
  737. }
  738.  
  739.  
  740.  
  741. /*
  742. EXEC SQL COMMENT ON  COLUMN BOX.B_SSN
  743.  
  744.          IS 'this is the associated customer ssn if the box is rented';
  745. */
  746.  
  747. {
  748.   sqlastrt(sqla_program_id,0L,&sqlca);
  749.   sqlacall((unsigned short)24,20,0,0,0L);
  750. if (sqlca.sqlcode < 0)
  751. {
  752.    sqlastop(0L);
  753.    goto stop_datab;
  754. }
  755.  
  756.   sqlastop(0L);
  757. }
  758.  
  759.  
  760.  
  761. /*
  762. EXEC SQL COMMENT ON  COLUMN BOX.B_PAYUP
  763.  
  764.          IS 'shows what month the box is paid up for if rented';
  765. */
  766.  
  767. {
  768.   sqlastrt(sqla_program_id,0L,&sqlca);
  769.   sqlacall((unsigned short)24,21,0,0,0L);
  770. if (sqlca.sqlcode < 0)
  771. {
  772.    sqlastop(0L);
  773.    goto stop_datab;
  774. }
  775.  
  776.   sqlastop(0L);
  777. }
  778.  
  779.  
  780.  
  781. /***************************************       ******************/
  782. /*****************************************************************************/
  783. /*      Create the CHECKING base table                                       */
  784. /*****************************************************************************/
  785.  
  786.      strcpy(rte_label,"create chk tbl ");
  787.  
  788.  
  789. /*
  790. EXEC SQL CREATE TABLE CHECKING
  791.    (C_ACCNUMB  CHAR      (8)   NOT NULL PRIMARY KEY,
  792.     C_STARTBAL DECIMAL (9,2)   NOT NULL,
  793.     C_ENDBAL   DECIMAL (9,2)   NOT NULL,
  794.     C_SSN1     CHAR     (11)   NOT NULL,
  795.     C_SSN2     CHAR     (11)           );
  796. */
  797.  
  798. {
  799.   sqlastrt(sqla_program_id,0L,&sqlca);
  800.   sqlacall((unsigned short)24,22,0,0,0L);
  801. if (sqlca.sqlcode < 0)
  802. {
  803.    sqlastop(0L);
  804.    goto stop_datab;
  805. }
  806.  
  807.   sqlastop(0L);
  808. }
  809.  
  810.  
  811.      strcpy(rte_label,"chkg tbl commt ");   /* define table comment */
  812.  
  813.  
  814. /*
  815. EXEC SQL COMMENT ON TABLE CHECKING
  816.  
  817.          IS 'This is the checking table of the BANK data base';
  818. */
  819.  
  820. {
  821.   sqlastrt(sqla_program_id,0L,&sqlca);
  822.   sqlacall((unsigned short)24,23,0,0,0L);
  823. if (sqlca.sqlcode < 0)
  824. {
  825.    sqlastop(0L);
  826.    goto stop_datab;
  827. }
  828.  
  829.   sqlastop(0L);
  830. }
  831.  
  832.  
  833.  
  834.      strcpy(rte_label,"chkg col commts");  /* define column comments  */
  835.  
  836.  
  837. /*
  838. EXEC SQL COMMENT ON  COLUMN CHECKING.C_ACCNUMB
  839.  
  840.          IS 'checking account number: table key';
  841. */
  842.  
  843. {
  844.   sqlastrt(sqla_program_id,0L,&sqlca);
  845.   sqlacall((unsigned short)24,24,0,0,0L);
  846. if (sqlca.sqlcode < 0)
  847. {
  848.    sqlastop(0L);
  849.    goto stop_datab;
  850. }
  851.  
  852.   sqlastop(0L);
  853. }
  854.  
  855.  
  856.  
  857. /*
  858. EXEC SQL COMMENT ON  COLUMN CHECKING.C_STARTBAL
  859.  
  860.          IS 'starting balance of the checking account';
  861. */
  862.  
  863. {
  864.   sqlastrt(sqla_program_id,0L,&sqlca);
  865.   sqlacall((unsigned short)24,25,0,0,0L);
  866. if (sqlca.sqlcode < 0)
  867. {
  868.    sqlastop(0L);
  869.    goto stop_datab;
  870. }
  871.  
  872.   sqlastop(0L);
  873. }
  874.  
  875.  
  876.  
  877. /*
  878. EXEC SQL COMMENT ON  COLUMN CHECKING.C_ENDBAL
  879.  
  880.          IS 'ending balance of the checking account';
  881. */
  882.  
  883. {
  884.   sqlastrt(sqla_program_id,0L,&sqlca);
  885.   sqlacall((unsigned short)24,26,0,0,0L);
  886. if (sqlca.sqlcode < 0)
  887. {
  888.    sqlastop(0L);
  889.    goto stop_datab;
  890. }
  891.  
  892.   sqlastop(0L);
  893. }
  894.  
  895.  
  896.  
  897. /*
  898. EXEC SQL COMMENT ON  COLUMN CHECKING.C_SSN1
  899.  
  900.          IS 'primary customer ssn associated with this checking account';
  901. */
  902.  
  903. {
  904.   sqlastrt(sqla_program_id,0L,&sqlca);
  905.   sqlacall((unsigned short)24,27,0,0,0L);
  906. if (sqlca.sqlcode < 0)
  907. {
  908.    sqlastop(0L);
  909.    goto stop_datab;
  910. }
  911.  
  912.   sqlastop(0L);
  913. }
  914.  
  915.  
  916.  
  917. /*
  918. EXEC SQL COMMENT ON  COLUMN CHECKING.C_SSN2
  919.  
  920.          IS 'optional: secondary customer ssn associated with this account';
  921. */
  922.  
  923. {
  924.   sqlastrt(sqla_program_id,0L,&sqlca);
  925.   sqlacall((unsigned short)24,28,0,0,0L);
  926. if (sqlca.sqlcode < 0)
  927. {
  928.    sqlastop(0L);
  929.    goto stop_datab;
  930. }
  931.  
  932.   sqlastop(0L);
  933. }
  934.  
  935.  
  936.  
  937. /***************************************       ******************/
  938. /*****************************************************************************/
  939. /*      Create the CREDITS base table                                        */
  940. /*****************************************************************************/
  941.  
  942.      strcpy(rte_label,"create cred tbl");
  943.  
  944.  
  945. /*
  946. EXEC SQL CREATE TABLE CREDITS
  947.    (CR_ACCNUMB   CHAR      (8)   NOT NULL,
  948.     CR_TRANDATE  CHAR      (8)   NOT NULL,
  949.     CR_DEPAMT    DECIMAL (8,2)   NOT NULL);
  950. */
  951.  
  952. {
  953.   sqlastrt(sqla_program_id,0L,&sqlca);
  954.   sqlacall((unsigned short)24,29,0,0,0L);
  955. if (sqlca.sqlcode < 0)
  956. {
  957.    sqlastop(0L);
  958.    goto stop_datab;
  959. }
  960.  
  961.   sqlastop(0L);
  962. }
  963.  
  964.  
  965.  
  966.      strcpy(rte_label,"cred tbl commt ");    /* define table comment */
  967.                                         /* define table comment */
  968.  
  969. /*
  970. EXEC SQL COMMENT ON TABLE CREDITS
  971.  
  972.          IS 'This is the credits table of the BANK data base';
  973. */
  974.  
  975. {
  976.   sqlastrt(sqla_program_id,0L,&sqlca);
  977.   sqlacall((unsigned short)24,30,0,0,0L);
  978. if (sqlca.sqlcode < 0)
  979. {
  980.    sqlastop(0L);
  981.    goto stop_datab;
  982. }
  983.  
  984.   sqlastop(0L);
  985. }
  986.  
  987.  
  988.  
  989.      strcpy(rte_label,"cred col commts");
  990.  
  991.                                         /* define comments for columns */
  992.  
  993. /*
  994. EXEC SQL COMMENT ON  COLUMN CREDITS.CR_ACCNUMB
  995.  
  996.          IS 'associated checking account number: table key';
  997. */
  998.  
  999. {
  1000.   sqlastrt(sqla_program_id,0L,&sqlca);
  1001.   sqlacall((unsigned short)24,31,0,0,0L);
  1002. if (sqlca.sqlcode < 0)
  1003. {
  1004.    sqlastop(0L);
  1005.    goto stop_datab;
  1006. }
  1007.  
  1008.   sqlastop(0L);
  1009. }
  1010.  
  1011.  
  1012.  
  1013. /*
  1014. EXEC SQL COMMENT ON  COLUMN CREDITS.CR_TRANDATE
  1015.  
  1016.          IS 'credit transaction date';
  1017. */
  1018.  
  1019. {
  1020.   sqlastrt(sqla_program_id,0L,&sqlca);
  1021.   sqlacall((unsigned short)24,32,0,0,0L);
  1022. if (sqlca.sqlcode < 0)
  1023. {
  1024.    sqlastop(0L);
  1025.    goto stop_datab;
  1026. }
  1027.  
  1028.   sqlastop(0L);
  1029. }
  1030.  
  1031.  
  1032.  
  1033. /*
  1034. EXEC SQL COMMENT ON  COLUMN CREDITS.CR_DEPAMT
  1035.  
  1036.          IS 'amount of deposit made to the checking account';
  1037. */
  1038.  
  1039. {
  1040.   sqlastrt(sqla_program_id,0L,&sqlca);
  1041.   sqlacall((unsigned short)24,33,0,0,0L);
  1042. if (sqlca.sqlcode < 0)
  1043. {
  1044.    sqlastop(0L);
  1045.    goto stop_datab;
  1046. }
  1047.  
  1048.   sqlastop(0L);
  1049. }
  1050.  
  1051.  
  1052.  
  1053. /***************************************       ******************/
  1054. /*****************************************************************************/
  1055. /*      Create the  DEBITS base table                                        */
  1056. /*****************************************************************************/
  1057.  
  1058.      strcpy(rte_label,"create debs tbl");
  1059.  
  1060.  
  1061. /*
  1062. EXEC SQL CREATE TABLE DEBITS
  1063.    (DB_ACCNUMB   CHAR      (8)   NOT NULL,
  1064.     DB_TRANDATE  CHAR      (8)   NOT NULL,
  1065.     DB_AMT       DECIMAL (8,2)   NOT NULL,
  1066.     DB_CHECKNO   CHAR      (5)   NOT NULL);
  1067. */
  1068.  
  1069. {
  1070.   sqlastrt(sqla_program_id,0L,&sqlca);
  1071.   sqlacall((unsigned short)24,34,0,0,0L);
  1072. if (sqlca.sqlcode < 0)
  1073. {
  1074.    sqlastop(0L);
  1075.    goto stop_datab;
  1076. }
  1077.  
  1078.   sqlastop(0L);
  1079. }
  1080.  
  1081.  
  1082.  
  1083.      strcpy(rte_label,"debs tbl commt ");   /* define table comment */
  1084.  
  1085.  
  1086. /*
  1087. EXEC SQL COMMENT ON TABLE DEBITS
  1088.  
  1089.          IS 'This is the debits table of the BANK data base';
  1090. */
  1091.  
  1092. {
  1093.   sqlastrt(sqla_program_id,0L,&sqlca);
  1094.   sqlacall((unsigned short)24,35,0,0,0L);
  1095. if (sqlca.sqlcode < 0)
  1096. {
  1097.    sqlastop(0L);
  1098.    goto stop_datab;
  1099. }
  1100.  
  1101.   sqlastop(0L);
  1102. }
  1103.  
  1104.  
  1105.  
  1106.      strcpy(rte_label,"debs col commts");   /* define comments for columns  */
  1107.  
  1108.  
  1109. /*
  1110. EXEC SQL COMMENT ON  COLUMN DEBITS.DB_ACCNUMB
  1111.  
  1112.          IS 'associated checking account number: table key';
  1113. */
  1114.  
  1115. {
  1116.   sqlastrt(sqla_program_id,0L,&sqlca);
  1117.   sqlacall((unsigned short)24,36,0,0,0L);
  1118. if (sqlca.sqlcode < 0)
  1119. {
  1120.    sqlastop(0L);
  1121.    goto stop_datab;
  1122. }
  1123.  
  1124.   sqlastop(0L);
  1125. }
  1126.  
  1127.  
  1128.  
  1129. /*
  1130. EXEC SQL COMMENT ON  COLUMN DEBITS.DB_TRANDATE
  1131.  
  1132.          IS 'debit transaction date';
  1133. */
  1134.  
  1135. {
  1136.   sqlastrt(sqla_program_id,0L,&sqlca);
  1137.   sqlacall((unsigned short)24,37,0,0,0L);
  1138. if (sqlca.sqlcode < 0)
  1139. {
  1140.    sqlastop(0L);
  1141.    goto stop_datab;
  1142. }
  1143.  
  1144.   sqlastop(0L);
  1145. }
  1146.  
  1147.  
  1148.  
  1149. /*
  1150. EXEC SQL COMMENT ON  COLUMN DEBITS.DB_AMT
  1151.  
  1152.          IS 'amount of the debit made from checking account';
  1153. */
  1154.  
  1155. {
  1156.   sqlastrt(sqla_program_id,0L,&sqlca);
  1157.   sqlacall((unsigned short)24,38,0,0,0L);
  1158. if (sqlca.sqlcode < 0)
  1159. {
  1160.    sqlastop(0L);
  1161.    goto stop_datab;
  1162. }
  1163.  
  1164.   sqlastop(0L);
  1165. }
  1166.  
  1167.  
  1168.  
  1169. /*
  1170. EXEC SQL COMMENT ON  COLUMN DEBITS.DB_CHECKNO
  1171.  
  1172.          IS 'check number associated with the debit';
  1173. */
  1174.  
  1175. {
  1176.   sqlastrt(sqla_program_id,0L,&sqlca);
  1177.   sqlacall((unsigned short)24,39,0,0,0L);
  1178. if (sqlca.sqlcode < 0)
  1179. {
  1180.    sqlastop(0L);
  1181.    goto stop_datab;
  1182. }
  1183.  
  1184.   sqlastop(0L);
  1185. }
  1186.  
  1187.  
  1188.  
  1189. /***************************************       ******************/
  1190. /*****************************************************************************/
  1191. /*      Create the LOAN base table                                           */
  1192. /*****************************************************************************/
  1193.  
  1194.      strcpy(rte_label,"create loan tbl");
  1195.  
  1196.  
  1197. /*
  1198. EXEC SQL CREATE TABLE LOAN
  1199.    (L_NUMB     CHAR      (8)   NOT NULL,
  1200.     L_TYPE     CHAR      (1)   NOT NULL,
  1201.     L_RATE     DECIMAL (4,2)   NOT NULL,
  1202.     L_TERM     SMALLINT        NOT NULL,
  1203.     L_PAYMT    DECIMAL (7,2)   NOT NULL,
  1204.     L_BAL      DECIMAL (8,2)   NOT NULL,
  1205.     L_INTODAT  DECIMAL (8,2)           ,
  1206.     L_SSN      CHAR     (11)   NOT NULL,
  1207.     L_DESCRIP  CHAR     (25)   NOT NULL,
  1208.     L_DATE     DATE            NOT NULL);
  1209. */
  1210.  
  1211. {
  1212.   sqlastrt(sqla_program_id,0L,&sqlca);
  1213.   sqlacall((unsigned short)24,40,0,0,0L);
  1214. if (sqlca.sqlcode < 0)
  1215. {
  1216.    sqlastop(0L);
  1217.    goto stop_datab;
  1218. }
  1219.  
  1220.   sqlastop(0L);
  1221. }
  1222.  
  1223.  
  1224.  
  1225.      strcpy(rte_label,"loan tbl commt ");   /* define table comment  */
  1226.  
  1227.  
  1228. /*
  1229. EXEC SQL COMMENT ON TABLE LOAN
  1230.  
  1231.          IS 'This is the loan table of the BANK data base';
  1232. */
  1233.  
  1234. {
  1235.   sqlastrt(sqla_program_id,0L,&sqlca);
  1236.   sqlacall((unsigned short)24,41,0,0,0L);
  1237. if (sqlca.sqlcode < 0)
  1238. {
  1239.    sqlastop(0L);
  1240.    goto stop_datab;
  1241. }
  1242.  
  1243.   sqlastop(0L);
  1244. }
  1245.  
  1246.  
  1247.      strcpy(rte_label,"loan col commts");   /* define column comments */
  1248.  
  1249.  
  1250. /*
  1251. EXEC SQL COMMENT ON  COLUMN LOAN.L_NUMB
  1252.  
  1253.          IS 'loan number: table key';
  1254. */
  1255.  
  1256. {
  1257.   sqlastrt(sqla_program_id,0L,&sqlca);
  1258.   sqlacall((unsigned short)24,42,0,0,0L);
  1259. if (sqlca.sqlcode < 0)
  1260. {
  1261.    sqlastop(0L);
  1262.    goto stop_datab;
  1263. }
  1264.  
  1265.   sqlastop(0L);
  1266. }
  1267.  
  1268.  
  1269.  
  1270. /*
  1271. EXEC SQL COMMENT ON  COLUMN LOAN.L_TYPE
  1272.  
  1273.          IS 'type of loan: M, A, P, H, or O';
  1274. */
  1275.  
  1276. {
  1277.   sqlastrt(sqla_program_id,0L,&sqlca);
  1278.   sqlacall((unsigned short)24,43,0,0,0L);
  1279. if (sqlca.sqlcode < 0)
  1280. {
  1281.    sqlastop(0L);
  1282.    goto stop_datab;
  1283. }
  1284.  
  1285.   sqlastop(0L);
  1286. }
  1287.  
  1288.  
  1289.  
  1290. /*
  1291. EXEC SQL COMMENT ON  COLUMN LOAN.L_RATE
  1292.  
  1293.          IS 'loan interest rate';
  1294. */
  1295.  
  1296. {
  1297.   sqlastrt(sqla_program_id,0L,&sqlca);
  1298.   sqlacall((unsigned short)24,44,0,0,0L);
  1299. if (sqlca.sqlcode < 0)
  1300. {
  1301.    sqlastop(0L);
  1302.    goto stop_datab;
  1303. }
  1304.  
  1305.   sqlastop(0L);
  1306. }
  1307.  
  1308.  
  1309.  
  1310. /*
  1311. EXEC SQL COMMENT ON  COLUMN LOAN.L_TERM
  1312.  
  1313.          IS 'term of loan in months';
  1314. */
  1315.  
  1316. {
  1317.   sqlastrt(sqla_program_id,0L,&sqlca);
  1318.   sqlacall((unsigned short)24,45,0,0,0L);
  1319. if (sqlca.sqlcode < 0)
  1320. {
  1321.    sqlastop(0L);
  1322.    goto stop_datab;
  1323. }
  1324.  
  1325.   sqlastop(0L);
  1326. }
  1327.  
  1328.  
  1329.  
  1330. /*
  1331. EXEC SQL COMMENT ON  COLUMN LOAN.L_PAYMT
  1332.  
  1333.          IS 'amount of loan payment per month';
  1334. */
  1335.  
  1336. {
  1337.   sqlastrt(sqla_program_id,0L,&sqlca);
  1338.   sqlacall((unsigned short)24,46,0,0,0L);
  1339. if (sqlca.sqlcode < 0)
  1340. {
  1341.    sqlastop(0L);
  1342.    goto stop_datab;
  1343. }
  1344.  
  1345.   sqlastop(0L);
  1346. }
  1347.  
  1348.  
  1349.  
  1350. /*
  1351. EXEC SQL COMMENT ON  COLUMN LOAN.L_BAL
  1352.  
  1353.          IS 'remaining balance of the loan';
  1354. */
  1355.  
  1356. {
  1357.   sqlastrt(sqla_program_id,0L,&sqlca);
  1358.   sqlacall((unsigned short)24,47,0,0,0L);
  1359. if (sqlca.sqlcode < 0)
  1360. {
  1361.    sqlastop(0L);
  1362.    goto stop_datab;
  1363. }
  1364.  
  1365.   sqlastop(0L);
  1366. }
  1367.  
  1368.  
  1369.  
  1370. /*
  1371. EXEC SQL COMMENT ON  COLUMN LOAN.L_INTODAT
  1372.  
  1373.          IS 'interest paid to date';
  1374. */
  1375.  
  1376. {
  1377.   sqlastrt(sqla_program_id,0L,&sqlca);
  1378.   sqlacall((unsigned short)24,48,0,0,0L);
  1379. if (sqlca.sqlcode < 0)
  1380. {
  1381.    sqlastop(0L);
  1382.    goto stop_datab;
  1383. }
  1384.  
  1385.   sqlastop(0L);
  1386. }
  1387.  
  1388.  
  1389.  
  1390. /*
  1391. EXEC SQL COMMENT ON  COLUMN LOAN.L_SSN
  1392.  
  1393.          IS 'associated customer ssn';
  1394. */
  1395.  
  1396. {
  1397.   sqlastrt(sqla_program_id,0L,&sqlca);
  1398.   sqlacall((unsigned short)24,49,0,0,0L);
  1399. if (sqlca.sqlcode < 0)
  1400. {
  1401.    sqlastop(0L);
  1402.    goto stop_datab;
  1403. }
  1404.  
  1405.   sqlastop(0L);
  1406. }
  1407.  
  1408.  
  1409.  
  1410. /*
  1411. EXEC SQL COMMENT ON  COLUMN LOAN.L_DESCRIP
  1412.  
  1413.          IS 'description of the specific loan';
  1414. */
  1415.  
  1416. {
  1417.   sqlastrt(sqla_program_id,0L,&sqlca);
  1418.   sqlacall((unsigned short)24,50,0,0,0L);
  1419. if (sqlca.sqlcode < 0)
  1420. {
  1421.    sqlastop(0L);
  1422.    goto stop_datab;
  1423. }
  1424.  
  1425.   sqlastop(0L);
  1426. }
  1427.  
  1428.  
  1429.  
  1430. /*
  1431. EXEC SQL COMMENT ON  COLUMN LOAN.L_DATE
  1432.  
  1433.          IS 'date the loan was initiated';
  1434. */
  1435.  
  1436. {
  1437.   sqlastrt(sqla_program_id,0L,&sqlca);
  1438.   sqlacall((unsigned short)24,51,0,0,0L);
  1439. if (sqlca.sqlcode < 0)
  1440. {
  1441.    sqlastop(0L);
  1442.    goto stop_datab;
  1443. }
  1444.  
  1445.   sqlastop(0L);
  1446. }
  1447.  
  1448.  
  1449. /***************************************       ******************/
  1450. /*****************************************************************************/
  1451. /*      Create the SAVINGS base table                                        */
  1452. /*****************************************************************************/
  1453.  
  1454.      strcpy(rte_label,"create savg tbl");
  1455.  
  1456.  
  1457. /*
  1458. EXEC SQL CREATE TABLE SAVINGS
  1459.    (S_ACCNUMB  CHAR      (8)   NOT NULL,
  1460.     S_IRATE    DECIMAL (4,2)   NOT NULL,
  1461.     S_INTTOD   DECIMAL (7,2)           ,
  1462.     S_BAL      DECIMAL (9,2)   NOT NULL,
  1463.     S_SSN      CHAR     (11)   NOT NULL);
  1464. */
  1465.  
  1466. {
  1467.   sqlastrt(sqla_program_id,0L,&sqlca);
  1468.   sqlacall((unsigned short)24,52,0,0,0L);
  1469. if (sqlca.sqlcode < 0)
  1470. {
  1471.    sqlastop(0L);
  1472.    goto stop_datab;
  1473. }
  1474.  
  1475.   sqlastop(0L);
  1476. }
  1477.  
  1478. /***********************************************************************/
  1479. /* CUSTOMER SAVINGS LOANS CREDITS AND BOX are combined to form another */
  1480. /* table   PERFDAT3                                                    */
  1481. /***********************************************************************/
  1482.    printf("\n creating table PERFDAT3 \n");
  1483.    
  1484. /*
  1485. EXEC SQL
  1486. CREATE TABLE PERFDAT3
  1487. (CU_SSN  CHAR(11)  NOT NULL, CU_NAME CHAR(30) NOT NULL, CU_ADDR1 CHAR(25) NOT NULL, CU_ADDR2 CHAR(25) NOT NULL,
  1488. CU_ZIP CHAR(5) NOT NULL,L_NUMB CHAR(8) NOT NULL, L_TYPE CHAR(1) NOT NULL, L_RATE DECIMAL(5,2) NOT NULL,
  1489. L_TERM SMALLINT NOT NULL,L_PAYMT DECIMAL (7,2) NOT NULL, L_BAL DECIMAL(9,2) NOT NULL, L_INTODAT DECIMAL(9,2),
  1490. L_DESCRIP CHAR(25) NOT NULL, L_DATE DATE, S_ACCNUMB CHAR(8) NOT NULL, S_IRATE DECIMAL(5,2) NOT NULL,
  1491. S_INTTOD DECIMAL(7,2), S_BAL DECIMAL(9,2) NOT NULL, B_NUMB CHAR(3) NOT NULL, B_SIZE CHAR(1) NOT NULL,
  1492. B_RENT DECIMAL(3,2) NOT NULL, B_PAYUP CHAR(3), C_ACCNUMB CHAR(8) NOT NULL, C_STARTBAL DECIMAL(9,2) NOT NULL,
  1493. C_ENDBAL DECIMAL(9,2) NOT NULL);
  1494. */
  1495.  
  1496. {
  1497.   sqlastrt(sqla_program_id,0L,&sqlca);
  1498.   sqlacall((unsigned short)24,53,0,0,0L);
  1499. if (sqlca.sqlcode < 0)
  1500. {
  1501.    sqlastop(0L);
  1502.    goto stop_datab;
  1503. }
  1504.  
  1505.   sqlastop(0L);
  1506. }
  1507.  
  1508.  
  1509.    printf("\n creating table PERFDAt4 \n");
  1510.    
  1511. /*
  1512. EXEC SQL
  1513. CREATE TABLE PERFDAt4
  1514. (CU_SSN  CHAR(11)  NOT NULL, CU_NAME CHAR(30) NOT NULL, CU_ADDR1 CHAR(25) NOT NULL, CU_ADDR2 CHAR(25) NOT NULL,
  1515. CU_ZIP CHAR(5) NOT NULL,L_NUMB CHAR(8) NOT NULL, L_TYPE CHAR(1) NOT NULL, L_RATE DECIMAL(5,2) NOT NULL,
  1516. L_TERM SMALLINT NOT NULL,L_PAYMT DECIMAL (7,2) NOT NULL, L_BAL DECIMAL(9,2) NOT NULL, L_INTODAT DECIMAL(9,2),
  1517. L_DESCRIP CHAR(25) NOT NULL, L_DATE DATE, S_ACCNUMB CHAR(8) NOT NULL, S_IRATE DECIMAL(5,2) NOT NULL,
  1518. S_INTTOD DECIMAL(7,2), S_BAL DECIMAL(9,2) NOT NULL, B_NUMB CHAR(3) NOT NULL, B_SIZE CHAR(1) NOT NULL,
  1519. B_RENT DECIMAL(3,2) NOT NULL, B_PAYUP CHAR(3), C_ACCNUMB CHAR(8) NOT NULL, C_STARTBAL DECIMAL(9,2) NOT NULL,
  1520. C_ENDBAL DECIMAL(9,2) NOT NULL  );
  1521. */
  1522.  
  1523. {
  1524.   sqlastrt(sqla_program_id,0L,&sqlca);
  1525.   sqlacall((unsigned short)24,54,0,0,0L);
  1526. if (sqlca.sqlcode < 0)
  1527. {
  1528.    sqlastop(0L);
  1529.    goto stop_datab;
  1530. }
  1531.  
  1532.   sqlastop(0L);
  1533. }
  1534.  
  1535.  
  1536.  
  1537.      strcpy(rte_label,"savg tbl commt ");  /* define table comment */
  1538.  
  1539.  
  1540. /*
  1541. EXEC SQL COMMENT ON TABLE SAVINGS
  1542.  
  1543.          IS 'This is the savings table of the BANK data base';
  1544. */
  1545.  
  1546. {
  1547.   sqlastrt(sqla_program_id,0L,&sqlca);
  1548.   sqlacall((unsigned short)24,55,0,0,0L);
  1549. if (sqlca.sqlcode < 0)
  1550. {
  1551.    sqlastop(0L);
  1552.    goto stop_datab;
  1553. }
  1554.  
  1555.   sqlastop(0L);
  1556. }
  1557.  
  1558.  
  1559.      strcpy(rte_label,"savg col commts");  /* define column comments */
  1560.  
  1561.  
  1562. /*
  1563. EXEC SQL COMMENT ON  COLUMN SAVINGS.S_ACCNUMB
  1564.  
  1565.          IS 'savings account number: table key';
  1566. */
  1567.  
  1568. {
  1569.   sqlastrt(sqla_program_id,0L,&sqlca);
  1570.   sqlacall((unsigned short)24,56,0,0,0L);
  1571. if (sqlca.sqlcode < 0)
  1572. {
  1573.    sqlastop(0L);
  1574.    goto stop_datab;
  1575. }
  1576.  
  1577.   sqlastop(0L);
  1578. }
  1579.  
  1580.  
  1581.  
  1582. /*
  1583. EXEC SQL COMMENT ON  COLUMN SAVINGS.S_IRATE
  1584.  
  1585.          IS 'rate of interest paid';
  1586. */
  1587.  
  1588. {
  1589.   sqlastrt(sqla_program_id,0L,&sqlca);
  1590.   sqlacall((unsigned short)24,57,0,0,0L);
  1591. if (sqlca.sqlcode < 0)
  1592. {
  1593.    sqlastop(0L);
  1594.    goto stop_datab;
  1595. }
  1596.  
  1597.   sqlastop(0L);
  1598. }
  1599.  
  1600.  
  1601.  
  1602. /*
  1603. EXEC SQL COMMENT ON  COLUMN SAVINGS.S_INTTOD
  1604.  
  1605.          IS 'interest earned to date';
  1606. */
  1607.  
  1608. {
  1609.   sqlastrt(sqla_program_id,0L,&sqlca);
  1610.   sqlacall((unsigned short)24,58,0,0,0L);
  1611. if (sqlca.sqlcode < 0)
  1612. {
  1613.    sqlastop(0L);
  1614.    goto stop_datab;
  1615. }
  1616.  
  1617.   sqlastop(0L);
  1618. }
  1619.  
  1620.  
  1621.  
  1622. /*
  1623. EXEC SQL COMMENT ON  COLUMN SAVINGS.S_BAL
  1624.  
  1625.          IS 'savings account balance';
  1626. */
  1627.  
  1628. {
  1629.   sqlastrt(sqla_program_id,0L,&sqlca);
  1630.   sqlacall((unsigned short)24,59,0,0,0L);
  1631. if (sqlca.sqlcode < 0)
  1632. {
  1633.    sqlastop(0L);
  1634.    goto stop_datab;
  1635. }
  1636.  
  1637.   sqlastop(0L);
  1638. }
  1639.  
  1640.  
  1641.  
  1642. /*
  1643. EXEC SQL COMMENT ON  COLUMN SAVINGS.S_SSN
  1644.  
  1645.          IS 'associated customer.ssn';
  1646. */
  1647.  
  1648. {
  1649.   sqlastrt(sqla_program_id,0L,&sqlca);
  1650.   sqlacall((unsigned short)24,60,0,0,0L);
  1651. if (sqlca.sqlcode < 0)
  1652. {
  1653.    sqlastop(0L);
  1654.    goto stop_datab;
  1655. }
  1656.  
  1657.   sqlastop(0L);
  1658. }
  1659.  
  1660.  
  1661. /*****************************************************************************/
  1662.  
  1663.  
  1664. /***************************************       ******************/
  1665. /*****************************************************************************/
  1666. /* STOP USING DATABASE AND EXIT PROGRAM                                      */
  1667. /*****************************************************************************/
  1668. stop_datab:
  1669.  
  1670.     strcpy(rte_label,"stop using dbas");
  1671.  
  1672.         if (sqlca.sqlcode != 0)
  1673.         {
  1674.              goto exit_error;             /* exit the program due to error   */
  1675.         }
  1676.  
  1677.         sqlestpd (&sqlca);                /* stop using the database         */
  1678.         goto exit_normal;                 /* terminate normally              */
  1679.  
  1680. /*****************************************************************************/
  1681.  
  1682. exit_error:
  1683.  
  1684.         errorlvl = 2;                          /* set return code - 2 (error)*/
  1685.  
  1686.  rc = sqlaintp (msgbuf,512,0,&sqlca);
  1687.  
  1688.  if (rc > 0)
  1689.  {
  1690.                                              /* Set up error file processing */
  1691.  
  1692.     if ((ptr_output = fopen(errorfle,"w")) == NULL)    /* open the error file*/
  1693.     {
  1694.  
  1695.         printf ("\nUNABLE TO OPEN D30ACBB1.ERR");      /* display on screen  */
  1696.         printf ("\nSQLCODE IS %ld",sqlca.sqlcode);
  1697.         goto exit_normal;
  1698.  
  1699.     }
  1700.                                               /* print error information     */
  1701.         fprintf (ptr_output,"%s\n%s\n",tcaseid,descript);
  1702.         fprintf (ptr_output,"%s\n",rte_label);
  1703.         fprintf (ptr_output,"SQLCODE is %ld.\n",sqlca.sqlcode);
  1704.         fprintf (ptr_output,msgbuf);
  1705.                                               /* SQL miscellaneous error info*/
  1706.  
  1707.         fprintf(ptr_output,"\nSQLERRD[0] is %ld",sqlca.sqlerrd[0]);
  1708.         fprintf(ptr_output,"\nSQLERRD[1] is %ld",sqlca.sqlerrd[1]);
  1709.         fprintf(ptr_output,"\nSQLERRD[2] is %ld",sqlca.sqlerrd[2]);
  1710.         fprintf(ptr_output,"\nSQLERRD[3] is %ld",sqlca.sqlerrd[3]);
  1711.         fprintf(ptr_output,"\nSQLERRD[4] is %ld",sqlca.sqlerrd[4]);
  1712.         fprintf(ptr_output,"\nSQLERRD[5] is %ld",sqlca.sqlerrd[5]);
  1713.  
  1714.         memcpy (sqlerrp_value, sqlca.sqlerrp,8);
  1715.         fprintf(ptr_output,"\nSQLERRP is %s",sqlerrp_value);
  1716.  
  1717.  
  1718.         fclose(ptr_output);                    /* close the output file      */
  1719.         sqlestpd (&sqlca);                     /* stop using the database    */
  1720.  
  1721.  }
  1722.  
  1723. /*****************************************************************************/
  1724.  
  1725. exit_normal:
  1726.  
  1727.         return (errorlvl);                        /* DOS error return code   */
  1728.  
  1729.  }
  1730.