?? lcloc.cpp
字號:
#include "oradb.h"void C_MYSQL::DbLCLOCTest(){ S_LCLOC pIn9; S_RESULT pOut9; memset(&pIn9,0,sizeof(pIn9)); memcpy(pIn9.LocationAreaCode,"11111111111",4); memcpy(pIn9.RoutingAreaCode,"11111111",5); memcpy(pIn9.CellIdentity,"11111111",4); snprintf(pIn9.ChangeTime,LEN_DATETIME + 1,"2"); snprintf(pIn9.TableName,LEN_TABLENAME + 1,"LCLOC"); snprintf(pIn9.SeqId,LEN_SEQ + 1,"2"); snprintf(pIn9.SortId,LEN_SORT+1,"2"); DbLCLOCInsert(&pIn9, &pOut9);}int C_MYSQL::DbLCLOCInsert(struct S_LCLOC* pIn, struct S_RESULT* pOut){ char szMsg[512]; char* TableName = (char*)pIn->TableName; char* SeqId = (char*)pIn->SeqId; char* LocationAreaCode = (char*)pIn->LocationAreaCode; char* RoutingAreaCode = (char*)pIn->RoutingAreaCode; char* CellIdentity = pIn->CellIdentity; char* ChangeTime = pIn->ChangeTime; char* SortId = pIn->SortId; int i=0; char szSQL[SQLMAX]; snprintf(szSQL, SQLMAX, "INSERT INTO %s (" "SEQID," "LOCATIONAREACODE," "ROUTINGAREACODE," "CELLIDENTITY," "SORTID," "CHANGETIME" ") VALUES(" "%s,'%s','%s','%s',%s,'%s')", TableName, SeqId[0]==0?"NULL":SeqId, LocationAreaCode, RoutingAreaCode, CellIdentity, SortId[0]==0?"NULL":SortId, ChangeTime );#ifdef _DEBUG logOra(sErrLog, szSQL);#endif Lock(); int res = mysql_real_query(myConnect, szSQL, strlen(szSQL)); if(res != 0) { Unlock(); onError(); return -1; } Unlock(); return 0;}int C_MYSQL::DbLCLOCSelect(char* pInSzTableName, char* pInSzSeqId, struct S_LCLOC** pOutLChangeLocation, int * number, struct S_RESULT* pOut){ char szMsg[512]; char SeqId[LEN_SEQ + 1]; char LocationAreaCode[5]; char RoutingAreaCode[9]; char CellIdentity[5]; char ChangeTime[LEN_DATETIME + 1]; char SortId[LEN_SORT+1]; struct S_LCLOC *pLCLOC = *pOutLChangeLocation; int nNumber = 0; char szSQL[SQLMAX]; char szSQL2[SQLMAX]; struct S_LCLOC* p2; int j; char * sz ; short id[5]; *number = 0; if(pLCLOC != NULL) { return -1; } snprintf(szSQL, SQLMAX, "SELECT SEQID,LOCATIONAREACODE, ROUTINGAREACODE, CELLIDENTITY, " "DATE_FORMAT(CHANGETIME,'%%Y%%m%%d%%H%%i%%s')," "SORTID " "FROM %s WHERE SEQID=%s", pInSzTableName, pInSzSeqId);#ifdef _DEBUG#ifdef LOG_SELECT logOra(sErrLog, szSQL);#endif#endif Lock(); snprintf(szSQL2, SQLMAX, "SELECT COUNT(*) FROM %s WHERE SEQID=%s", pInSzTableName, pInSzSeqId); nNumber=DbCount(szSQL2,myConnect); if(nNumber <= 0) { Unlock(); *number = 0; return 0; } sz = (char *)malloc(SIZE_S_LCLOC*nNumber); memset(sz, 0, SIZE_S_LCLOC*nNumber); mysql_real_query(myConnect, szSQL, strlen(szSQL)); MYSQL_RES *res_ptr = mysql_store_result(myConnect); if (res_ptr == NULL) { Unlock(); onError(); return -1; } MYSQL_ROW sqlrow;#ifdef _DEBUG logOra(sErrLog, "CURSOR...");#endif for(j=0;j<nNumber;j++) { sqlrow = mysql_fetch_row(res_ptr); p2 = (struct S_LCLOC*)&sz[SIZE_S_LCLOC*j]; if (sqlrow[0] != NULL) memcpy(p2->SeqId, sqlrow[0], 20); if (sqlrow[1] != NULL) memcpy(p2->LocationAreaCode, sqlrow[1], 4); if (sqlrow[2] != NULL) memcpy(p2->RoutingAreaCode, sqlrow[2], 8); if (sqlrow[3] != NULL) memcpy(p2->CellIdentity, sqlrow[3], 4); if (sqlrow[4] != NULL) memcpy(p2->ChangeTime, sqlrow[4], LEN_DATETIME); if (sqlrow[5] != NULL) memcpy(p2->SortId, sqlrow[5], LEN_SORT); if (pInSzTableName != NULL) memcpy(p2->TableName, pInSzTableName, LEN_TABLENAME); } * pOutLChangeLocation = (struct S_LCLOC*)sz; * number = nNumber; mysql_free_result(res_ptr); Unlock(); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -