void DbGpfsInfo::upsertInfo(SQLHSTMT sqlStmt) { removeRows(sqlStmt,tmptableName); //clear all related temp tables at first fillTable(sqlStmt,tmptableName); //fill temp table queryTable(sqlStmt,tmptableName,&tempInfo);//query temp table queryTable(sqlStmt,tableName,&lastInfo); //query regular table updateRegularTable(sqlStmt,tableName, tempInfo, lastInfo); //update regular table }
// word parse void parse() { int i = 0; char ch; wordlen = 0; for (; i < finalInputlen; ++i) { memset(gBuf,0,BUFSIZ); ch = finalInput[i]; int j=0; if (isalpha(ch)) { gBuf[j++] = ch; ch = finalInput[++i]; while(isalpha(ch) || isdigit(ch)) { gBuf[j++] = ch; ch = finalInput[++i]; } i--; if (queryTable(gBuf) != -1) { wordIndex[wordlen] = queryTable(gBuf); strcpy(wordResult[wordlen++],gBuf); } else { wordIndex[wordlen] = 10; strcpy(wordResult[wordlen++],gBuf); } } else if (isdigit(ch)||ch == '+'||ch == '-') { gBuf[j++] = ch; if (isdigit(ch)) { ch = finalInput[++i]; digit(ch,&i,&j,&wordlen); } else { ch = finalInput[++i]; if (!isdigit(ch)) { wordIndex[wordlen] = queryTable(gBuf); strcpy(wordResult[wordlen++],gBuf); i--; continue; } else { if ((((i>=2)&&( isdigit(finalInput[i-2]) || isalpha(finalInput[i-2])))||(finalInput[i-2]==')')) ||((i>=3)&&(isspace(finalInput[i-2]) && (isdigit(finalInput[i-3]) || isalpha(finalInput[i-3])) ))){ wordIndex[wordlen] = queryTable(gBuf); strcpy(wordResult[wordlen++],gBuf); i--; continue; } digit(ch,&i,&j,&wordlen); } } } else { switch(ch) { case ' ':break; case '>':{ ch = finalInput[++i]; if (ch == '=') { wordIndex[wordlen] = queryTable(">="); strcpy(wordResult[wordlen++],">="); } else { wordIndex[wordlen] = queryTable(">"); strcpy(wordResult[wordlen++],">"); i--; } };break; case '<':{ ch = finalInput[++i]; if (ch == '=') { wordIndex[wordlen] = queryTable("<="); strcpy(wordResult[wordlen++],"<="); } else { wordIndex[wordlen] = queryTable("<"); strcpy(wordResult[wordlen++],"<"); i--; } };break; case '=':{ ch = finalInput[++i]; if (ch == '=') { wordIndex[wordlen] = queryTable("=="); strcpy(wordResult[wordlen++],"=="); } else { wordIndex[wordlen] = queryTable("="); strcpy(wordResult[wordlen++],"="); i--; } };break; case '!':{ ch = finalInput[++i]; if (ch == '=') { wordIndex[wordlen] = queryTable("!="); strcpy(wordResult[wordlen++],"!="); } else { wordIndex[wordlen] = -1; strcpy(wordResult[wordlen++],"! is error,this is not a recognised letter"); i--; } };break; default: gBuf[j++] = ch; wordIndex[wordlen] = queryTable(gBuf); if (queryTable(gBuf) != -1) { strcpy(wordResult[wordlen++],gBuf); } else { char strtemp[BUFSIZ]; strcpy(strtemp,gBuf); strcat(strtemp," is error. This is not a recognised letter"); strcpy(wordResult[wordlen++],strtemp); } break; } } } }