everything seems to work now; changed from test to actual database
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -145,27 +145,27 @@ void insertCategory(){
|
|||||||
|
|
||||||
|
|
||||||
#line 133 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 133 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char eingna [ 51 ] ;
|
char eingna [ 4001 ] ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 134 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 134 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
|
||||||
string h = "";
|
string h = "";
|
||||||
cout << "Eingabe Name: ";
|
cout << "Eingabe Name: ";
|
||||||
getline(cin, h);
|
ws(cin);
|
||||||
getline(cin, h);
|
getline(cin, h);
|
||||||
|
|
||||||
//cout << h << endl;
|
//cout << h << endl;
|
||||||
if (!(h.empty()||!strcmp(h.c_str(),"\n")))
|
if (!(h.empty()||!strcmp(h.c_str(),"\n")))
|
||||||
{
|
{
|
||||||
strcpy(eingna, h.c_str());
|
strcpy(eingna, h.c_str());
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into gr2 . test ( name ) values ( $1 )",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into gr2 . \"Categories\" ( name ) values ( $1 )",
|
||||||
ECPGt_char,(eingna),(long)51,(long)1,(51)*sizeof(char),
|
ECPGt_char,(eingna),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 145 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 145 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if (!strcmp(sqlca.sqlstate, "23505")) cout << "GIBT'S SCHON" << endl;
|
if (!strcmp(sqlca.sqlstate, "23505")) cout << "GIBT'S SCHON" << endl;
|
||||||
cout << "state: " << sqlca.sqlstate << endl;
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 148 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 148 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
@@ -182,19 +182,19 @@ void insertQuestion(){
|
|||||||
|
|
||||||
|
|
||||||
#line 154 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 154 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char question [ 181 ] ;
|
char question [ 4001 ] ;
|
||||||
|
|
||||||
#line 155 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 155 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans0 [ 181 ] ;
|
char ans0 [ 4001 ] ;
|
||||||
|
|
||||||
#line 156 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 156 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans1 [ 181 ] ;
|
char ans1 [ 4001 ] ;
|
||||||
|
|
||||||
#line 157 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 157 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans2 [ 181 ] ;
|
char ans2 [ 4001 ] ;
|
||||||
|
|
||||||
#line 158 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 158 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans3 [ 181 ] ;
|
char ans3 [ 4001 ] ;
|
||||||
|
|
||||||
#line 159 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 159 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int category ;
|
int category ;
|
||||||
@@ -203,38 +203,44 @@ void insertQuestion(){
|
|||||||
|
|
||||||
|
|
||||||
cout << "Frage: ";
|
cout << "Frage: ";
|
||||||
cin >> question;
|
ws(cin);
|
||||||
|
cin.getline(question, sizeof(question));
|
||||||
cout << "Richtige Antwort: ";
|
cout << "Richtige Antwort: ";
|
||||||
cin >> ans0;
|
ws(cin);
|
||||||
|
cin.getline(ans0, sizeof(ans0));
|
||||||
cout << "1. Falsche Antwort: ";
|
cout << "1. Falsche Antwort: ";
|
||||||
cin >> ans1;
|
ws(cin);
|
||||||
|
cin.getline(ans1, sizeof(ans1));
|
||||||
cout << "2. Falsche Antwort: ";
|
cout << "2. Falsche Antwort: ";
|
||||||
cin >> ans2;
|
ws(cin);
|
||||||
|
cin.getline(ans2, sizeof(ans2));
|
||||||
cout << "3. Falsche Antwort: ";
|
cout << "3. Falsche Antwort: ";
|
||||||
cin >> ans3;
|
ws(cin);
|
||||||
|
cin.getline(ans3, sizeof(ans3));
|
||||||
cout << "ID der Kategorie:" << endl << "moegliche ";
|
cout << "ID der Kategorie:" << endl << "moegliche ";
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> category;
|
cin >> category;
|
||||||
if(category){
|
if(category){
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into gr2 . testquestions ( question , answer0 , answer1 , answer2 , answer3 , category ) values ( $1 , $2 , $3 , $4 , $5 , $6 )",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into gr2 . \"Questions\" ( question , answer0 , answer1 , answer2 , answer3 , category ) values ( $1 , $2 , $3 , $4 , $5 , $6 )",
|
||||||
ECPGt_char,(question),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(question),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans0),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans0),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans1),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans1),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans2),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans2),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans3),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans3),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(category),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(category),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 176 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 181 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Das ist keine gueltige Kategorie!" << endl;
|
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Das ist keine gueltige Kategorie!" << endl;
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
cout << "state: " << sqlca.sqlstate << endl;
|
cout << "state: " << sqlca.sqlstate << endl;
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 179 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 185 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,35 +251,41 @@ void selectCategory(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 186 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 192 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
|
|
||||||
#line 187 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 193 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char name [ 51 ] ;
|
char name [ 4001 ] ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 188 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 194 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
|
||||||
cout << "Kategorien:" << endl;
|
cout << "Kategorien:" << endl;
|
||||||
|
|
||||||
/* declare xxx cursor for select \"ID\" , name from gr2 . test order by \"ID\" */
|
/* declare xxx cursor for select \"ID\" , name from gr2 . \"Categories\" order by \"ID\" */
|
||||||
#line 192 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 198 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare xxx cursor for select \"ID\" , name from gr2 . test order by \"ID\"", ECPGt_EOIT, ECPGt_EORT);}
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare xxx cursor for select \"ID\" , name from gr2 . \"Categories\" order by \"ID\"", ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 193 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 199 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
|
||||||
int residl;
|
int residl;
|
||||||
residl = id;
|
residl = id;
|
||||||
|
|
||||||
|
string hName = "";
|
||||||
|
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch first from xxx", ECPGt_EOIT,
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch first from xxx", ECPGt_EOIT,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(name),(long)51,(long)1,(51)*sizeof(char),
|
ECPGt_char,(name),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||||
#line 198 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 206 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "00000")) cout << id << " " << name << endl;
|
if(!strcmp(sqlca.sqlstate, "00000")){
|
||||||
|
hName = name;
|
||||||
|
hName.erase(hName.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << id << " " << hName << endl;
|
||||||
|
}
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
||||||
|
|
||||||
while(id != residl)
|
while(id != residl)
|
||||||
@@ -282,14 +294,18 @@ void selectCategory(){
|
|||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from xxx", ECPGt_EOIT,
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from xxx", ECPGt_EOIT,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(name),(long)51,(long)1,(51)*sizeof(char),
|
ECPGt_char,(name),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||||
#line 205 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 217 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "00000")) cout << id << " " << name << endl;
|
if(!strcmp(sqlca.sqlstate, "00000")){
|
||||||
|
hName = name;
|
||||||
|
hName.erase(hName.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << id << " " << hName << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 208 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 224 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,39 +320,63 @@ void selectQuestion(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 214 "F:\\postgrachelor\\project\\dbclient.pgc"
|
|
||||||
|
|
||||||
|
#line 230 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
|
|
||||||
#line 215 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 231 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char question [ 181 ] ;
|
char question [ 4001 ] ;
|
||||||
|
|
||||||
#line 216 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 232 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans0 [ 181 ] ;
|
char ans0 [ 4001 ] ;
|
||||||
|
|
||||||
#line 217 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 233 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans1 [ 181 ] ;
|
char ans1 [ 4001 ] ;
|
||||||
|
|
||||||
#line 218 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 234 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans2 [ 181 ] ;
|
char ans2 [ 4001 ] ;
|
||||||
|
|
||||||
#line 219 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 235 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans3 [ 181 ] ;
|
char ans3 [ 4001 ] ;
|
||||||
|
|
||||||
#line 220 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 236 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char cat [ 51 ] ;
|
char cat [ 4001 ] ;
|
||||||
|
|
||||||
|
#line 237 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
int sites ;
|
||||||
|
|
||||||
|
#line 238 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
int offset ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 221 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 239 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
|
||||||
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ceil ( count ( * ) / 5.0 ) from gr2 . \"Questions\"", ECPGt_EOIT,
|
||||||
|
ECPGt_int,&(sites),(long)1,(long)1,sizeof(int),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||||
|
#line 241 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
cout << "Es gibt " << sites << " Seiten. Welche soll angezeigt werden?" << endl;
|
||||||
|
cin >> offset;
|
||||||
|
while(offset > sites || offset < 1){
|
||||||
|
cout << "Diese Seite gibt es nicht. Bitte gueltige Seitenzahl eingeben!" << endl;
|
||||||
|
cin >> offset;
|
||||||
|
}
|
||||||
|
offset = (offset-1)*5;
|
||||||
|
|
||||||
string hQuestion = "", hAns0 = "", hAns1 = "", hAns2 = "", hAns3 = "", hCat = "";
|
string hQuestion = "", hAns0 = "", hAns1 = "", hAns2 = "", hAns3 = "", hCat = "";
|
||||||
|
|
||||||
cout << "Fragen:" << endl << endl;
|
cout << "Fragen:" << endl << endl;
|
||||||
|
|
||||||
/* declare yyy cursor for select q . \"ID\" , q . question , q . answer0 , q . answer1 , q . answer2 , q . answer3 , c . name from gr2 . testquestions q join gr2 . test c on q . \"ID\" = c . \"ID\" order by c . \"ID\" */
|
ECPGset_var( 0, &( offset ), __LINE__);\
|
||||||
#line 227 "F:\\postgrachelor\\project\\dbclient.pgc"
|
/* declare yyy cursor for select q . \"ID\" , q . question , q . answer0 , q . answer1 , q . answer2 , q . answer3 , c . name from gr2 . \"Questions\" q join gr2 . \"Categories\" c on q . category = c . \"ID\" order by c . \"ID\" limit 5 offset $1 */
|
||||||
|
#line 254 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare yyy cursor for select q . \"ID\" , q . question , q . answer0 , q . answer1 , q . answer2 , q . answer3 , c . name from gr2 . testquestions q join gr2 . test c on q . \"ID\" = c . \"ID\" order by c . \"ID\"", ECPGt_EOIT, ECPGt_EORT);}
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare yyy cursor for select q . \"ID\" , q . question , q . answer0 , q . answer1 , q . answer2 , q . answer3 , c . name from gr2 . \"Questions\" q join gr2 . \"Categories\" c on q . category = c . \"ID\" order by c . \"ID\" limit 5 offset $1 ",
|
||||||
#line 228 "F:\\postgrachelor\\project\\dbclient.pgc"
|
ECPGt_int,&(offset),(long)1,(long)1,sizeof(int),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
|
#line 255 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
|
||||||
int residl;
|
int residl;
|
||||||
@@ -345,60 +385,17 @@ void selectQuestion(){
|
|||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch first from yyy", ECPGt_EOIT,
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch first from yyy", ECPGt_EOIT,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(question),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(question),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans0),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans0),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans1),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans1),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans2),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans2),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(ans3),(long)181,(long)1,(181)*sizeof(char),
|
ECPGt_char,(ans3),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_char,(cat),(long)51,(long)1,(51)*sizeof(char),
|
ECPGt_char,(cat),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
|
||||||
#line 233 "F:\\postgrachelor\\project\\dbclient.pgc"
|
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "00000")){
|
|
||||||
hQuestion = question;
|
|
||||||
hAns0 = ans0;
|
|
||||||
hAns1 = ans1;
|
|
||||||
hAns2 = ans2;
|
|
||||||
hAns3 = ans3;
|
|
||||||
hCat = cat;
|
|
||||||
hQuestion.erase(hQuestion.find_last_not_of(" \n\r\t")+1);
|
|
||||||
hAns0.erase(hAns0.find_last_not_of(" \n\r\t")+1);
|
|
||||||
hAns1.erase(hAns1.find_last_not_of(" \n\r\t")+1);
|
|
||||||
hAns2.erase(hAns2.find_last_not_of(" \n\r\t")+1);
|
|
||||||
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
|
||||||
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
|
||||||
cout << "Schema:" << endl;
|
|
||||||
cout << "Frage: Kategorie" << endl << "\tRichtige Antwort" << endl << "\tFalsche Antwort 1" << endl << "\tFalsche Antwort 2" << endl << "\tFalsche Antwort 3" << endl << endl << endl;
|
|
||||||
cout << hQuestion << ": " << hCat << endl;
|
|
||||||
cout << "\t" << hAns0 << endl;
|
|
||||||
cout << "\t" << hAns1 << endl;
|
|
||||||
cout << "\t" << hAns2 << endl;
|
|
||||||
cout << "\t" << hAns3 << endl;
|
|
||||||
}
|
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
|
||||||
|
|
||||||
while(id != residl)
|
|
||||||
{
|
|
||||||
residl = id;
|
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from yyy", ECPGt_EOIT,
|
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(question),(long)181,(long)1,(181)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(ans0),(long)181,(long)1,(181)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(ans1),(long)181,(long)1,(181)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(ans2),(long)181,(long)1,(181)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(ans3),(long)181,(long)1,(181)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
|
||||||
ECPGt_char,(cat),(long)51,(long)1,(51)*sizeof(char),
|
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||||
#line 260 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 260 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
@@ -415,15 +412,58 @@ void selectQuestion(){
|
|||||||
hAns2.erase(hAns2.find_last_not_of(" \n\r\t")+1);
|
hAns2.erase(hAns2.find_last_not_of(" \n\r\t")+1);
|
||||||
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
||||||
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << "Schema:" << endl;
|
||||||
|
cout << "Frage: Kategorie" << endl << " Richtige Antwort" << endl << " Falsche Antwort 1" << endl << " Falsche Antwort 2" << endl << " Falsche Antwort 3" << endl << endl << endl;
|
||||||
cout << hQuestion << ": " << hCat << endl;
|
cout << hQuestion << ": " << hCat << endl;
|
||||||
cout << "\t" << hAns0 << endl;
|
cout << " " << hAns0 << endl;
|
||||||
cout << "\t" << hAns1 << endl;
|
cout << " " << hAns1 << endl;
|
||||||
cout << "\t" << hAns2 << endl;
|
cout << " " << hAns2 << endl;
|
||||||
cout << "\t" << hAns3 << endl;
|
cout << " " << hAns3 << endl;
|
||||||
|
}
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
||||||
|
|
||||||
|
while(id != residl)
|
||||||
|
{
|
||||||
|
residl = id;
|
||||||
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from yyy", ECPGt_EOIT,
|
||||||
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(question),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(ans0),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(ans1),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(ans2),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(ans3),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
|
ECPGt_char,(cat),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||||
|
#line 287 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
|
if(!strcmp(sqlca.sqlstate, "00000")){
|
||||||
|
hQuestion = question;
|
||||||
|
hAns0 = ans0;
|
||||||
|
hAns1 = ans1;
|
||||||
|
hAns2 = ans2;
|
||||||
|
hAns3 = ans3;
|
||||||
|
hCat = cat;
|
||||||
|
hQuestion.erase(hQuestion.find_last_not_of(" \n\r\t")+1);
|
||||||
|
hAns0.erase(hAns0.find_last_not_of(" \n\r\t")+1);
|
||||||
|
hAns1.erase(hAns1.find_last_not_of(" \n\r\t")+1);
|
||||||
|
hAns2.erase(hAns2.find_last_not_of(" \n\r\t")+1);
|
||||||
|
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
||||||
|
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << hQuestion << ": " << hCat << endl;
|
||||||
|
cout << " " << hAns0 << endl;
|
||||||
|
cout << " " << hAns1 << endl;
|
||||||
|
cout << " " << hAns2 << endl;
|
||||||
|
cout << " " << hAns3 << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 281 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 308 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,30 +472,32 @@ void updateCategory(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 286 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 313 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
|
|
||||||
#line 287 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 314 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char name [ 51 ] ;
|
char name [ 4001 ] ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 288 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 315 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
cout << "Welche Kategorie soll bearbeitet werden? (ID eingeben):" << endl;
|
cout << "Welche Kategorie soll bearbeitet werden? (ID eingeben):" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
cout << "Welchen neuen Namen soll die Kategorie bekommen?" << endl;
|
cout << "Welchen neuen Namen soll die Kategorie bekommen?" << endl;
|
||||||
cin >> name;
|
ws(cin);
|
||||||
|
cin.getline(name, sizeof(name));
|
||||||
if(id){
|
if(id){
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . test set name = $1 where \"ID\" = $2 ",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Categories\" set name = $1 where \"ID\" = $2 ",
|
||||||
ECPGt_char,(name),(long)51,(long)1,(51)*sizeof(char),
|
ECPGt_char,(name),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 295 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 323 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 297 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 326 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -470,28 +512,28 @@ void updateQuestion(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 303 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 332 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
|
|
||||||
#line 304 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 333 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char question [ 181 ] ;
|
char question [ 4001 ] ;
|
||||||
|
|
||||||
#line 305 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 334 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans0 [ 181 ] ;
|
char ans0 [ 4001 ] ;
|
||||||
|
|
||||||
#line 306 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 335 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans1 [ 181 ] ;
|
char ans1 [ 4001 ] ;
|
||||||
|
|
||||||
#line 307 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 336 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans2 [ 181 ] ;
|
char ans2 [ 4001 ] ;
|
||||||
|
|
||||||
#line 308 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 337 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
char ans3 [ 181 ] ;
|
char ans3 [ 4001 ] ;
|
||||||
|
|
||||||
#line 309 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 338 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int cat ;
|
int cat ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 310 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 339 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
char choice = 0;
|
char choice = 0;
|
||||||
cout << "Welche Frage soll bearbeitet werden? (ID eingeben):" << endl;
|
cout << "Welche Frage soll bearbeitet werden? (ID eingeben):" << endl;
|
||||||
@@ -502,74 +544,81 @@ void updateQuestion(){
|
|||||||
switch(choice){
|
switch(choice){
|
||||||
case 'f':
|
case 'f':
|
||||||
cout << "Neue Fragenstellung: ";
|
cout << "Neue Fragenstellung: ";
|
||||||
cin >> question;
|
ws(cin);
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set question = $1 where \"ID\" = $2 ",
|
cin.getline(question, sizeof(question));
|
||||||
ECPGt_char,(question),(long)181,(long)1,(181)*sizeof(char),
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set question = $1 where \"ID\" = $2 ",
|
||||||
|
ECPGt_char,(question),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 321 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 351 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
cout << "Neue richtige Antwort: ";
|
cout << "Neue richtige Antwort: ";
|
||||||
cin >> ans0;
|
ws(cin);
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set answer0 = $1 where \"ID\" = $2 ",
|
cin.getline(ans0, sizeof(ans0));
|
||||||
ECPGt_char,(ans0),(long)181,(long)1,(181)*sizeof(char),
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set answer0 = $1 where \"ID\" = $2 ",
|
||||||
|
ECPGt_char,(ans0),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 326 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 357 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans1;
|
ws(cin);
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set answer1 = $1 where \"ID\" = $2 ",
|
cin.getline(ans1, sizeof(ans1));
|
||||||
ECPGt_char,(ans1),(long)181,(long)1,(181)*sizeof(char),
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set answer1 = $1 where \"ID\" = $2 ",
|
||||||
|
ECPGt_char,(ans1),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 331 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 363 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans2;
|
ws(cin);
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set answer2 = $1 where \"ID\" = $2 ",
|
cin.getline(ans2, sizeof(ans2));
|
||||||
ECPGt_char,(ans2),(long)181,(long)1,(181)*sizeof(char),
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set answer2 = $1 where \"ID\" = $2 ",
|
||||||
|
ECPGt_char,(ans2),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 336 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 369 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans3;
|
ws(cin);
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set answer3 = $1 where \"ID\" = $2 ",
|
cin.getline(ans3, sizeof(ans3));
|
||||||
ECPGt_char,(ans3),(long)181,(long)1,(181)*sizeof(char),
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set answer3 = $1 where \"ID\" = $2 ",
|
||||||
|
ECPGt_char,(ans3),(long)4001,(long)1,(4001)*sizeof(char),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 341 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 375 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
cout << "Neue Kategorie (ID):" << endl;
|
cout << "Neue Kategorie (ID):" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> cat;
|
cin >> cat;
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . testquestions set category = $1 where \"ID\" = $2 ",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update gr2 . \"Questions\" set category = $1 where \"ID\" = $2 ",
|
||||||
ECPGt_int,&(cat),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(cat),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 347 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 381 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 350 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 386 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -578,24 +627,24 @@ void deleteCategory(){
|
|||||||
/* exec sql begin declare section */
|
/* exec sql begin declare section */
|
||||||
|
|
||||||
|
|
||||||
#line 356 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 392 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 357 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 393 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
cout << "Welche Kategorie? (ID)" << endl;
|
cout << "Welche Kategorie? (ID)" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
if(id){
|
if(id){
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from gr2 . test where \"ID\" = $1 ",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from gr2 . \"Categories\" where \"ID\" = $1 ",
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 362 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 398 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Kategorie kann nicht geloescht werden! (Existieren noch Fragen mit der Kategorie?)" << endl;
|
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Kategorie kann nicht geloescht werden! (Existieren noch Fragen mit der Kategorie?)" << endl;
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kategorie existiert nicht!" << endl;
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kategorie existiert nicht!" << endl;
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 365 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 401 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -604,23 +653,23 @@ void deleteQuestion(){
|
|||||||
/* exec sql begin declare section */
|
/* exec sql begin declare section */
|
||||||
|
|
||||||
|
|
||||||
#line 371 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 407 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
int id ;
|
int id ;
|
||||||
/* exec sql end declare section */
|
/* exec sql end declare section */
|
||||||
#line 372 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 408 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
cout << "Welche Frage? (ID)" << endl;
|
cout << "Welche Frage? (ID)" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
if(id){
|
if(id){
|
||||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from gr2 . testquestions where \"ID\" = $1 ",
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from gr2 . \"Questions\" where \"ID\" = $1 ",
|
||||||
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
|
||||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||||
#line 377 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 413 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Frage existiert nicht!" << endl;
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Frage existiert nicht!" << endl;
|
||||||
{ ECPGtrans(__LINE__, NULL, "commit");}
|
{ ECPGtrans(__LINE__, NULL, "commit");}
|
||||||
#line 379 "F:\\postgrachelor\\project\\dbclient.pgc"
|
#line 415 "F:\\postgrachelor\\project\\dbclient.pgc"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,51 +130,57 @@ void menuDelete(){
|
|||||||
|
|
||||||
void insertCategory(){
|
void insertCategory(){
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
char eingna[51];
|
char eingna[4001];
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
|
|
||||||
string h = "";
|
string h = "";
|
||||||
cout << "Eingabe Name: ";
|
cout << "Eingabe Name: ";
|
||||||
getline(cin, h);
|
ws(cin);
|
||||||
getline(cin, h);
|
getline(cin, h);
|
||||||
|
|
||||||
//cout << h << endl;
|
//cout << h << endl;
|
||||||
if (!(h.empty()||!strcmp(h.c_str(),"\n")))
|
if (!(h.empty()||!strcmp(h.c_str(),"\n")))
|
||||||
{
|
{
|
||||||
strcpy(eingna, h.c_str());
|
strcpy(eingna, h.c_str());
|
||||||
EXEC SQL INSERT INTO gr2.test(name) VALUES (:eingna);
|
EXEC SQL INSERT INTO gr2."Categories"(name) VALUES (:eingna);
|
||||||
if (!strcmp(sqlca.sqlstate, "23505")) cout << "GIBT'S SCHON" << endl;
|
if (!strcmp(sqlca.sqlstate, "23505")) cout << "GIBT'S SCHON" << endl;
|
||||||
cout << "state: " << sqlca.sqlstate << endl;
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertQuestion(){
|
void insertQuestion(){
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
char question[181];
|
char question[4001];
|
||||||
char ans0[181];
|
char ans0[4001];
|
||||||
char ans1[181];
|
char ans1[4001];
|
||||||
char ans2[181];
|
char ans2[4001];
|
||||||
char ans3[181];
|
char ans3[4001];
|
||||||
int category;
|
int category;
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
|
|
||||||
cout << "Frage: ";
|
cout << "Frage: ";
|
||||||
cin >> question;
|
ws(cin);
|
||||||
|
cin.getline(question, sizeof(question));
|
||||||
cout << "Richtige Antwort: ";
|
cout << "Richtige Antwort: ";
|
||||||
cin >> ans0;
|
ws(cin);
|
||||||
|
cin.getline(ans0, sizeof(ans0));
|
||||||
cout << "1. Falsche Antwort: ";
|
cout << "1. Falsche Antwort: ";
|
||||||
cin >> ans1;
|
ws(cin);
|
||||||
|
cin.getline(ans1, sizeof(ans1));
|
||||||
cout << "2. Falsche Antwort: ";
|
cout << "2. Falsche Antwort: ";
|
||||||
cin >> ans2;
|
ws(cin);
|
||||||
|
cin.getline(ans2, sizeof(ans2));
|
||||||
cout << "3. Falsche Antwort: ";
|
cout << "3. Falsche Antwort: ";
|
||||||
cin >> ans3;
|
ws(cin);
|
||||||
|
cin.getline(ans3, sizeof(ans3));
|
||||||
cout << "ID der Kategorie:" << endl << "moegliche ";
|
cout << "ID der Kategorie:" << endl << "moegliche ";
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> category;
|
cin >> category;
|
||||||
if(category){
|
if(category){
|
||||||
EXEC SQL INSERT INTO gr2.testquestions(question,answer0,answer1,answer2,answer3,category) VALUES (:question,:ans0,:ans1,:ans2,:ans3,:category);
|
EXEC SQL INSERT INTO gr2."Questions"(question,answer0,answer1,answer2,answer3,category) VALUES (:question,:ans0,:ans1,:ans2,:ans3,:category);
|
||||||
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Das ist keine gueltige Kategorie!" << endl;
|
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Das ist keine gueltige Kategorie!" << endl;
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
cout << "state: " << sqlca.sqlstate << endl;
|
cout << "state: " << sqlca.sqlstate << endl;
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
@@ -184,26 +190,36 @@ void selectCategory(){
|
|||||||
//Die Ausgabe funktioniert nur dann korrekt, wenn die ids eindeutig sind!!!
|
//Die Ausgabe funktioniert nur dann korrekt, wenn die ids eindeutig sind!!!
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
int id;
|
int id;
|
||||||
char name[51];
|
char name[4001];
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
|
|
||||||
cout << "Kategorien:" << endl;
|
cout << "Kategorien:" << endl;
|
||||||
|
|
||||||
EXEC SQL DECLARE xxx CURSOR FOR SELECT "ID",name FROM gr2.test ORDER BY "ID";
|
EXEC SQL DECLARE xxx CURSOR FOR SELECT "ID",name FROM gr2."Categories" ORDER BY "ID";
|
||||||
EXEC SQL OPEN xxx;
|
EXEC SQL OPEN xxx;
|
||||||
|
|
||||||
int residl;
|
int residl;
|
||||||
residl = id;
|
residl = id;
|
||||||
|
|
||||||
|
string hName = "";
|
||||||
|
|
||||||
EXEC SQL FETCH FIRST FROM xxx INTO :id, :name;
|
EXEC SQL FETCH FIRST FROM xxx INTO :id, :name;
|
||||||
if(!strcmp(sqlca.sqlstate, "00000")) cout << id << " " << name << endl;
|
if(!strcmp(sqlca.sqlstate, "00000")){
|
||||||
|
hName = name;
|
||||||
|
hName.erase(hName.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << id << " " << hName << endl;
|
||||||
|
}
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
||||||
|
|
||||||
while(id != residl)
|
while(id != residl)
|
||||||
{
|
{
|
||||||
residl = id;
|
residl = id;
|
||||||
EXEC SQL FETCH NEXT FROM xxx INTO :id, :name;
|
EXEC SQL FETCH NEXT FROM xxx INTO :id, :name;
|
||||||
if(!strcmp(sqlca.sqlstate, "00000")) cout << id << " " << name << endl;
|
if(!strcmp(sqlca.sqlstate, "00000")){
|
||||||
|
hName = name;
|
||||||
|
hName.erase(hName.find_last_not_of(" \n\r\t")+1);
|
||||||
|
cout << id << " " << hName << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
@@ -212,19 +228,30 @@ void selectQuestion(){
|
|||||||
//Die Ausgabe funktioniert nur dann korrekt, wenn die ids eindeutig sind!!!
|
//Die Ausgabe funktioniert nur dann korrekt, wenn die ids eindeutig sind!!!
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
int id;
|
int id;
|
||||||
char question[181];
|
char question[4001];
|
||||||
char ans0[181];
|
char ans0[4001];
|
||||||
char ans1[181];
|
char ans1[4001];
|
||||||
char ans2[181];
|
char ans2[4001];
|
||||||
char ans3[181];
|
char ans3[4001];
|
||||||
char cat[51];
|
char cat[4001];
|
||||||
|
int sites;
|
||||||
|
int offset;
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
|
|
||||||
|
EXEC SQL SELECT ceil(count(*)/5.0) INTO :sites FROM gr2."Questions";
|
||||||
|
cout << "Es gibt " << sites << " Seiten. Welche soll angezeigt werden?" << endl;
|
||||||
|
cin >> offset;
|
||||||
|
while(offset > sites || offset < 1){
|
||||||
|
cout << "Diese Seite gibt es nicht. Bitte gueltige Seitenzahl eingeben!" << endl;
|
||||||
|
cin >> offset;
|
||||||
|
}
|
||||||
|
offset = (offset-1)*5;
|
||||||
|
|
||||||
string hQuestion = "", hAns0 = "", hAns1 = "", hAns2 = "", hAns3 = "", hCat = "";
|
string hQuestion = "", hAns0 = "", hAns1 = "", hAns2 = "", hAns3 = "", hCat = "";
|
||||||
|
|
||||||
cout << "Fragen:" << endl << endl;
|
cout << "Fragen:" << endl << endl;
|
||||||
|
|
||||||
EXEC SQL DECLARE yyy CURSOR FOR SELECT q."ID",q.question,q.answer0,q.answer1,q.answer2,q.answer3,c.name FROM gr2.testquestions q JOIN gr2.test c ON q."ID" = c."ID" ORDER BY c."ID";
|
EXEC SQL DECLARE yyy CURSOR FOR SELECT q."ID",q.question,q.answer0,q.answer1,q.answer2,q.answer3,c.name FROM gr2."Questions" q JOIN gr2."Categories" c ON q.category = c."ID" ORDER BY c."ID" LIMIT 5 OFFSET :offset;
|
||||||
EXEC SQL OPEN yyy;
|
EXEC SQL OPEN yyy;
|
||||||
|
|
||||||
int residl;
|
int residl;
|
||||||
@@ -245,12 +272,12 @@ void selectQuestion(){
|
|||||||
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
||||||
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
||||||
cout << "Schema:" << endl;
|
cout << "Schema:" << endl;
|
||||||
cout << "Frage: Kategorie" << endl << "\tRichtige Antwort" << endl << "\tFalsche Antwort 1" << endl << "\tFalsche Antwort 2" << endl << "\tFalsche Antwort 3" << endl << endl << endl;
|
cout << "Frage: Kategorie" << endl << " Richtige Antwort" << endl << " Falsche Antwort 1" << endl << " Falsche Antwort 2" << endl << " Falsche Antwort 3" << endl << endl << endl;
|
||||||
cout << hQuestion << ": " << hCat << endl;
|
cout << hQuestion << ": " << hCat << endl;
|
||||||
cout << "\t" << hAns0 << endl;
|
cout << " " << hAns0 << endl;
|
||||||
cout << "\t" << hAns1 << endl;
|
cout << " " << hAns1 << endl;
|
||||||
cout << "\t" << hAns2 << endl;
|
cout << " " << hAns2 << endl;
|
||||||
cout << "\t" << hAns3 << endl;
|
cout << " " << hAns3 << endl;
|
||||||
}
|
}
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Die Tabelle ist leer!";
|
||||||
|
|
||||||
@@ -272,10 +299,10 @@ void selectQuestion(){
|
|||||||
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
hAns3.erase(hAns3.find_last_not_of(" \n\r\t")+1);
|
||||||
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
hCat.erase(hCat.find_last_not_of(" \n\r\t")+1);
|
||||||
cout << hQuestion << ": " << hCat << endl;
|
cout << hQuestion << ": " << hCat << endl;
|
||||||
cout << "\t" << hAns0 << endl;
|
cout << " " << hAns0 << endl;
|
||||||
cout << "\t" << hAns1 << endl;
|
cout << " " << hAns1 << endl;
|
||||||
cout << "\t" << hAns2 << endl;
|
cout << " " << hAns2 << endl;
|
||||||
cout << "\t" << hAns3 << endl;
|
cout << " " << hAns3 << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
@@ -284,16 +311,18 @@ void selectQuestion(){
|
|||||||
void updateCategory(){
|
void updateCategory(){
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
int id;
|
int id;
|
||||||
char name[51];
|
char name[4001];
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
cout << "Welche Kategorie soll bearbeitet werden? (ID eingeben):" << endl;
|
cout << "Welche Kategorie soll bearbeitet werden? (ID eingeben):" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
cout << "Welchen neuen Namen soll die Kategorie bekommen?" << endl;
|
cout << "Welchen neuen Namen soll die Kategorie bekommen?" << endl;
|
||||||
cin >> name;
|
ws(cin);
|
||||||
|
cin.getline(name, sizeof(name));
|
||||||
if(id){
|
if(id){
|
||||||
EXEC SQL UPDATE gr2.test SET name = :name WHERE "ID" = :id;
|
EXEC SQL UPDATE gr2."Categories" SET name = :name WHERE "ID" = :id;
|
||||||
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,11 +330,11 @@ void updateCategory(){
|
|||||||
void updateQuestion(){
|
void updateQuestion(){
|
||||||
EXEC SQL BEGIN DECLARE SECTION;
|
EXEC SQL BEGIN DECLARE SECTION;
|
||||||
int id;
|
int id;
|
||||||
char question[181];
|
char question[4001];
|
||||||
char ans0[181];
|
char ans0[4001];
|
||||||
char ans1[181];
|
char ans1[4001];
|
||||||
char ans2[181];
|
char ans2[4001];
|
||||||
char ans3[181];
|
char ans3[4001];
|
||||||
int cat;
|
int cat;
|
||||||
EXEC SQL END DECLARE SECTION;
|
EXEC SQL END DECLARE SECTION;
|
||||||
char choice = 0;
|
char choice = 0;
|
||||||
@@ -317,36 +346,43 @@ void updateQuestion(){
|
|||||||
switch(choice){
|
switch(choice){
|
||||||
case 'f':
|
case 'f':
|
||||||
cout << "Neue Fragenstellung: ";
|
cout << "Neue Fragenstellung: ";
|
||||||
cin >> question;
|
ws(cin);
|
||||||
EXEC SQL UPDATE gr2.testquestions SET question = :question WHERE "ID" = :id;
|
cin.getline(question, sizeof(question));
|
||||||
|
EXEC SQL UPDATE gr2."Questions" SET question = :question WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
cout << "Neue richtige Antwort: ";
|
cout << "Neue richtige Antwort: ";
|
||||||
cin >> ans0;
|
ws(cin);
|
||||||
EXEC SQL UPDATE gr2.testquestions SET answer0 = :ans0 WHERE "ID" = :id;
|
cin.getline(ans0, sizeof(ans0));
|
||||||
|
EXEC SQL UPDATE gr2."Questions" SET answer0 = :ans0 WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans1;
|
ws(cin);
|
||||||
EXEC SQL UPDATE gr2.testquestions SET answer1 = :ans1 WHERE "ID" = :id;
|
cin.getline(ans1, sizeof(ans1));
|
||||||
|
EXEC SQL UPDATE gr2."Questions" SET answer1 = :ans1 WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans2;
|
ws(cin);
|
||||||
EXEC SQL UPDATE gr2.testquestions SET answer2 = :ans2 WHERE "ID" = :id;
|
cin.getline(ans2, sizeof(ans2));
|
||||||
|
EXEC SQL UPDATE gr2."Questions" SET answer2 = :ans2 WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
cout << "Neue falsche Antwort: ";
|
cout << "Neue falsche Antwort: ";
|
||||||
cin >> ans3;
|
ws(cin);
|
||||||
EXEC SQL UPDATE gr2.testquestions SET answer3 = :ans3 WHERE "ID" = :id;
|
cin.getline(ans3, sizeof(ans3));
|
||||||
|
EXEC SQL UPDATE gr2."Questions" SET answer3 = :ans3 WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
cout << "Neue Kategorie (ID):" << endl;
|
cout << "Neue Kategorie (ID):" << endl;
|
||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> cat;
|
cin >> cat;
|
||||||
EXEC SQL UPDATE gr2.testquestions SET category = :cat WHERE "ID" = :id;
|
EXEC SQL UPDATE gr2."Questions" SET category = :cat WHERE "ID" = :id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kein derartiger Datensatz gefunden!";
|
||||||
|
else if(!strcmp(sqlca.sqlstate, "22021")) cout << "Umlaute bitte umschreiben (z.B. als \"ue\")!";
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +395,7 @@ void deleteCategory(){
|
|||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
if(id){
|
if(id){
|
||||||
EXEC SQL DELETE FROM gr2.test WHERE "ID" = :id;
|
EXEC SQL DELETE FROM gr2."Categories" WHERE "ID" = :id;
|
||||||
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Kategorie kann nicht geloescht werden! (Existieren noch Fragen mit der Kategorie?)" << endl;
|
if(!strcmp(sqlca.sqlstate, "23503")) cout << "Kategorie kann nicht geloescht werden! (Existieren noch Fragen mit der Kategorie?)" << endl;
|
||||||
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kategorie existiert nicht!" << endl;
|
else if(!strcmp(sqlca.sqlstate, "02000")) cout << "Kategorie existiert nicht!" << endl;
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
@@ -374,7 +410,7 @@ void deleteQuestion(){
|
|||||||
selectCategory();
|
selectCategory();
|
||||||
cin >> id;
|
cin >> id;
|
||||||
if(id){
|
if(id){
|
||||||
EXEC SQL DELETE FROM gr2.testquestions WHERE "ID" = :id;
|
EXEC SQL DELETE FROM gr2."Questions" WHERE "ID" = :id;
|
||||||
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Frage existiert nicht!" << endl;
|
if(!strcmp(sqlca.sqlstate, "02000")) cout << "Frage existiert nicht!" << endl;
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1,6 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
|
1489999930 source:f:\postgrachelor\project\dbclient.pgc
|
||||||
|
<iostream>
|
||||||
|
<sstream>
|
||||||
|
<stdlib.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Release" />
|
||||||
<File name="dbclient.pgc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="dbclient.pgc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="10046" topLine="324" />
|
<Cursor1 position="224" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="dbclient.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="dbclient.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="3617" topLine="112" />
|
<Cursor1 position="5865" topLine="231" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|||||||
Reference in New Issue
Block a user