#include 
void main() {
  EXEC SQL BEGIN DECLARE SECTION;
    struct s_rec_type {
      char  sno[5];
      char  sname[20];
      char  city[15];
      int   status;
    } srec;
    varchar userid[10],password[15];
  EXEC SQL END DECLARE SECTION;

  FILE  *s;
  int   file_end;
 
  EXEC SQL INCLUDE SQLCA;
  EXEC SQL WHENEVER SQLERROR GOTO HANDLE_ERROR;

  printf("Enter your USERID: ");
  scanf("%s", userid.arr);
  userid.len = strlen(userid.arr);
  printf("Enter your PASSWORD: ");
  system("stty -echo");
  scanf("%s", password.arr);
  password.len = strlen(password.arr);
  system("stty echo");
  printf("\n");

  EXEC SQL CONNECT :userid IDENTIFIED BY :password;
  EXEC SQL SET TRANSACTION READ WRITE;

  s = fopen("s.dat","r");
  while ((file_end = 
            fscanf(s,"%s%s%s%d",&(srec.sno),&(srec.sname),
                                &(srec.city),&(srec.status))) != EOF)
     EXEC SQL INSERT INTO suppliers VALUES (:srec);
 
  EXEC SQL COMMIT;
  fclose(s);
  exit(0);

 HANDLE_ERROR: 
    printf("sqlca.sqlcode = %d\n",sqlca.sqlcode);
    printf("sqlca.sqlerrm = %s\n",sqlca.sqlerrm.sqlerrmc);
    printf("Some problem while inserting data\n");
    exit(1);
}