Simplified Embedded SQL program

Following is a simplified Embedded SQL program. At this point, you need not understand everything shown in the program. Its purpose is to demonstrate the parts of an Embedded SQL program. The details are explained in subsequent chapters.

 IDENTIFICATION DIVISION. 
  PROGRAM-ID. EXAMPLE. 
  ENVIRONMENT DIVISION. 
  DATA DIVISION. 
  WORKING-STORAGE SECTION. 
  
 * Communicating with Adaptive Server -  Chapter 3
      exec sql include sqlca end-exec.
  
 * Declaring variables  -  Chapter 4
 exec sql begin declare section end-exec 
 01  MY-ID           PIC X(30). 
 01  MYPASS          PIC X(30). 
 01  MYSERVER        PIC X(30). 
 exec sql end declare section end-exec.
 
 PROCEDURE DIVISION. 
 MAIN-SECTION. 
 PARA-1. 
 
 * Initializing error-handling routines - Chapter 8

 exec sql whenever sqlerror perform ERR-PARA  
 through ERR-PARA-END end-exec.
* Connecting to Adaptive Server - Chapter 5

     DISPLAY "PLEASE ENTER USER-ID". 
     ACCEPT MY-ID. 
     DISPLAY "PLEASE ENTER PASSWORD". 
     ACCEPT MYPASS. 
     DISPLAY "SERVER TO USE?". 
     ACCEPT MYSERVER. 
     exec sql connect :MY-ID identified by :MYPASS 
     using :MYSERVER end-exec. 
*Issuing Transact-SQL statements  -  Chapter 6 
 exec sql update alltypes set account = account * 2 end-exec. 
exec sql commit work end-exec.
*Closing connection to the server  -  Chapter 5  

 exec sql disconnect default end-exec. 
 STOP RUN. 
Error-handling routine  -  Chapter 8  

  ERR-PARA. 
      DISPLAY     " ERROR CODE "    SQLCODE
        " ERROR MESSAGE: "          SQLERRMC. 
  ERR-PARA-END.
END PROGRAM.