Simplified Embedded SQL program

Following is a simple 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.

/* Establishing a communication area - Chapter 3 */
  
 exec sql include sqlca; 
  
 main() 
 { 
  
 /* Declaring variables - Chapter 4 */
  
 exec sql begin declare section; 
 CS_CHAR  user[31], passwd[31]; 
 exec sql end declare section; 
      
 /*Initializing error-handling routines - Chapter 8 */
  
 exec sql whenever sqlerror call err_p(); 
  
 /*Establishing Adaptive Server Enterprise connections - Chapter 5 */
  
 printf("\nplease enter your userid "); 
 gets(user); 
 printf("\npassword "); 
 gets(passwd); 
 exec sql connect :user identified by :passwd; 
  
 /* Issuing Transact-SQL statements  -  Chapter 6 */
  
 exec sql update titles set price = price * 1.10; 
exec sql commit work;
  
 /* Closing server connections - Chapter 5 */
  
 exec sql disconnect all; 
 }

/* Error-handling routines - Chapter 8 */
  
 err_p() 
 { 
     /* Print the error code and error message */
 
  printf("\nError occurred: code %d.\n%s", 
     sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); 
 }