assgn4 - /* COURSE: SE6M03 * NAME: YIXIAN LUO * STU_NO.:...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
/* COURSE: SE6M03 * NAME: YIXIAN LUO * STU_NO.: 0901958 */ #include <stdio.h> #include <stdlib.h> #include <string.h> # EXEC SQL INCLUDE SQLCA; E void query1(); void query2(); void query3(); void query4(); void query5(); void query6(); void query7(); void query8(); v int connected=0; i /* function sqlerr---------------------------------- */ void sqlerr(char* x) { v if (SQLCODE!=0) { printf("error %s (%d)\n",x,SQLCODE); if (connected) { EXEC SQL CONNECT RESET; printf("disconnected from SE4M03\n"); } exit(1); } }/* end sqlerr */ } /* function connect---------------------------------- */ void connect() { v EXEC SQL CONNECT TO SE4M03; sqlerr("CONNECT TO SE4M03"); printf("Connected to SE4M03\n"); connected = 1; }/* end connect */ } /* function disconnect---------------------------------- */ void disconnect() { v EXEC SQL CONNECT RESET; sqlerr("CONNECT RESET"); printf("Disconnected from SE4M03\n"); connected = 0; }/* end disconnect */ } /* function depad--------------------------------------- */ void depad(char* s) { int i; i = strlen(s)-1; while(s[i]==' ') s[i--]='\0';
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
}/* end depad */ } char buffer[300]; c /* function main -------------------------------------- */ int main() { i int i, j; i connect(); c while(1) { w A: printf("enter number of query you want to execute (1-8), 0 to quit\n"); fgets(buffer,300,stdin); if (buffer[0]=='\n') { printf("nothing entered\n"); continue; } i=j=0; while(buffer[j]!='\n') { i = 10*i+buffer[i]-'0'; else{ printf("incorrect entry\n"); goto A; } j++; } if (i > 8) { printf("incorrect entry\n"); goto A; } if (i == 0) break; else if (i == 1) query1(); else if (i == 2) query2(); else if (i == 3) query3(); else if (i == 4) query4(); else if (i == 5) query5(); else if (i == 6) query6(); else if (i == 7) query7(); else if (i == 8) query8(); else printf("incorrect entry\n"); } disconnect(); return 0; }/* end main */ } int count; EXEC SQL BEGIN DECLARE SECTION; char employeeno[7]; char first[11]; char middle[11]; char last[21];
Background image of page 2
char area_code[4]; char number[7]; char assemblyno[7]; char partno[7]; sqlint32 orig_quantity; sqlint32 remaining_quantity; char bo_date[11]; char fd[11]; char backordered_by[7]; short mid_ind; char warehouseid[5]; sqlint32 binno; sqlint32 remaining_capacity; char managerno[7]; sqlint32 number_managed; EXEC SQL END DECLARE SECTION; E /* function query1---------------------------------- */ / void query1() { v printf("displaying query 1\n"); EXEC SQL DECLARE cur1 CURSOR FOR SELECT WORKER.EMPLOYEENO FROM WORKER, (SELECT MANAGER.EMPLOYEENO FROM MANAGER,HASNAME WHERE MANAGER.EMPLOYEENO=HASNAME.EMPLOYEENO
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

assgn4 - /* COURSE: SE6M03 * NAME: YIXIAN LUO * STU_NO.:...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online