#include "esqlx.h"
#line 1 "unio.ec"

#include<sys/types.h>
#include<sys/uio.h>
#include<unistd.h>
#include<time.h>
#include<sys/time.h>
#include<dbi.h>
#include<stdio.h>
main()
{

int  resultCount =0;
int last_timing=0;
int fresh_timing;
int Time_diff;
int id=0 ;
struct timeval time_sec;

{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 19 "unio.ec"
  uci_connect("sridhar", (char *)0, (char *)0);
#line 19 "unio.ec"
  uci_end();
#line 19 "unio.ec"
}

#line 20 "unio.ec"
uci_startup("unio.ec");
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 21 "unio.ec"
  uci_static(-1, "DROP emp10RES", 13, -1);
#line 21 "unio.ec"
  uci_end();
#line 21 "unio.ec"
}

#line 22 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 22 "unio.ec"
  uci_commit();
#line 22 "unio.ec"
  uci_end();
#line 22 "unio.ec"
}

#line 23 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 25 "unio.ec"
  uci_static(-1, "CREATE TABLE emp10RES (EID INTEGER,  StartDate DATE,  EndDate DATE)", 67, -1);
#line 25 "unio.ec"
  uci_end();
#line 25 "unio.ec"
}

#line 26 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 26 "unio.ec"
  uci_commit();
#line 26 "unio.ec"
  uci_end();
#line 26 "unio.ec"
}

#line 27 "unio.ec"

{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 28 "unio.ec"
  uci_static(-1, "SELECT COUNT(*) INTO ? FROM emp10", 33, 1);
#line 28 "unio.ec"
  uci_get_value(-1, NULL, (void *)(&(resultCount)), DB_TYPE_C_INT, (DB_INT32)(sizeof(int)), NULL);
#line 28 "unio.ec"
  uci_end();
#line 28 "unio.ec"
}

#line 29 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 29 "unio.ec"
  uci_commit();
#line 29 "unio.ec"
  uci_end();
#line 29 "unio.ec"
}

#line 30 "unio.ec"
  fprintf(stdout,"# of records to operate on: %d\n",resultCount);
gettimeofday(&time_sec,NULL); 
last_timing=(time_sec.tv_sec)*1000000+(time_sec.tv_usec);
printf("%d\n",last_timing);
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 65 "unio.ec"
  uci_static(-1, "INSERT INTO emp10RES SELECT E1.EID, E1.StartDate, E1.EndDate  FROM emp10 E1,"
#line 65 "unio.ec"
" emp10 E2  WHERE E1.MID = E2.EID AND  E1.Salary > E2.Salary AND  E2.StartDate <= E1.StartDate AND  E1.EndDate <= E2.EndDate UNION SELECT E1.EID,"
#line 65 "unio.ec"
" E1.StartDate,"
#line 65 "unio.ec"
" E2.EndDate  FROM emp10 E1, emp10 E2  WHERE E1.MID = E2.EID AND  E1.Salary > E2.Salary AND  E1.StartDate > E2.StartDate AND  E2.EndDate < E1.EndDate AND  E1.StartDate < E2.EndDate  UNION  SELECT E1.EID,"
#line 65 "unio.ec"
" E2.StartDate, E1.EndDate  FROM emp10 E1,"
#line 65 "unio.ec"
" emp10 E2  WHERE E1.MID = E2.EID AND  E1.Salary > E2.Salary AND  E2.StartDate > E1.StartDate AND  E1.EndDate < E2.EndDate AND  E2.StartDate < E1.EndDate  UNION  SELECT E1.EID,"
#line 65 "unio.ec"
" E2.StartDate, E2.EndDate  FROM emp10 E1,"
#line 65 "unio.ec"
" emp10 E2  WHERE E1.MID = E2.EID AND  E1.Salary > E2.Salary AND  E2.StartDate >= E1.StartDate AND  E2.EndDate <= E1.EndDate AND  NOT (E2.Startdate = E1.StartDate AND  E2.EndDate = E1.EndDate)", 884, -1);
#line 65 "unio.ec"
  uci_end();
#line 65 "unio.ec"
}

#line 66 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 66 "unio.ec"
  uci_commit();
#line 66 "unio.ec"
  uci_end();
#line 66 "unio.ec"
}

#line 67 "unio.ec"
gettimeofday(&time_sec,NULL);
fresh_timing=(time_sec.tv_sec)*1000000 + time_sec.tv_usec;
printf("%d\n",fresh_timing);
Time_diff=(fresh_timing-last_timing);
printf("[emp10 TJOIN UNION] Elapsed Time  :%d\n",Time_diff);
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 72 "unio.ec"
  uci_static(-1, "SELECT COUNT(*) INTO ? FROM emp10res", 36, 1);
#line 72 "unio.ec"
  uci_get_value(-1, NULL, (void *)(&(resultCount)), DB_TYPE_C_INT, (DB_INT32)(sizeof(int)), NULL);
#line 72 "unio.ec"
  uci_end();
#line 72 "unio.ec"
}

#line 73 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 73 "unio.ec"
  uci_commit();
#line 73 "unio.ec"
  uci_end();
#line 73 "unio.ec"
}

#line 74 "unio.ec"
printf("Resulting Records : %d\n",resultCount);  

#line 76 "unio.ec"
{ uci_start((void *)&uci_esqlxc_file, __FILE__, __LINE__); 
#line 76 "unio.ec"
  uci_disconnect();
#line 76 "unio.ec"
  uci_end();
#line 76 "unio.ec"
}

#line 77 "unio.ec"
}












