int Pgsql::CheckFilter(){ if(SelectSqlInt("select updated from update_check where value = 'filter'")){ ExecSql("update update_check set updated = 0 where value = 'filter'"); return 1; } return 0; }
void USQLiteDatabase::InsertRowsIntoTable(const FString DatabaseName, const FString TableName, TArray<FSQLiteTableRowSimulator> rowsOfFields){ for (FSQLiteTableRowSimulator row : rowsOfFields) { FString query = "INSERT INTO " + TableName + " ("; for (FSQLiteTableField field : row.rowsOfFields) { query += field.FieldName + ", "; } query = query.Left(query.Len() - 2); query = query + ") VALUES ("; for (FSQLiteTableField field : row.rowsOfFields) { if (field.FieldType.Equals(TEXT("TEXT"))) { query = query + "'" + field.FieldValue + "', "; } else { query = query + field.FieldValue + ", "; } } query = query.Left(query.Len() - 2); query = query + ");"; //LOGSQLITE(Warning, *query); ExecSql(DatabaseName, query); } }
void ConfDb::SetWindowY(int y) { FORMAT_SQL(SQL_UPDATE_CONF_INT, KEY_WND_Y, y, KEY_WND_Y); ExecSql(); }
void ConfDb::SetWindowX(int x) { FORMAT_SQL(SQL_UPDATE_CONF_INT, KEY_WND_X, x, KEY_WND_X); ExecSql(); }
void ConfDb::SetLastOpenPath(const string& path) { FORMAT_SQL(SQL_UPDATE_CONF_STR, KEY_LAST_OPEN_PATH, path.c_str(), KEY_LAST_OPEN_PATH); ExecSql(); }
void ConfDb::SetWindowHeight(int h) { FORMAT_SQL(SQL_UPDATE_CONF_INT, KEY_WND_HEIGHT, h, KEY_WND_HEIGHT); ExecSql(); }
void ConfDb::SetWindowWidth(int w) { FORMAT_SQL(SQL_UPDATE_CONF_INT, KEY_WND_WIDTH, w, KEY_WND_WIDTH); ExecSql(); }
void CDbHeartbeat::customEvent( QEvent *e ) { CDbHeartbeatEvent* pEvent = ( CDbHeartbeatEvent* ) e; CDbHeartbeatEvent::SqlHB event = ( CDbHeartbeatEvent::SqlHB ) e->type( ); QString& strSql = pEvent->GetSql( ); switch ( event ) { case CDbHeartbeatEvent::SqlData : ExecSql( strSql ); break; } }
FSQLiteTable USQLiteDatabase::CreateTable(const FString DatabaseName, const FString TableName, const TArray<FSQLiteTableField> Fields, const FSQLitePrimaryKey PK) { FSQLiteTable t; t.DatabaseName = DatabaseName; t.TableName = TableName; t.Fields = Fields; t.PK = PK; FString query = ""; query += "CREATE TABLE IF NOT EXISTS "; query += TableName; query += "("; bool singlePrimaryKeyExists = false; for (const FSQLiteTableField& field : Fields) { if (field.ResultStr.Len() > 2) { if (field.ResultStr.Contains("PRIMARY KEY")) { singlePrimaryKeyExists = true; } query += field.ResultStr + ", "; } } if (singlePrimaryKeyExists) { query = query.Left(query.Len() - 2); query += ");"; } else { if (PK.ResultStr.Len() > 2) { query += " " + PK.ResultStr + " "; } else { query = query.Left(query.Len() - 2); } query += ");"; } //LOGSQLITE(Warning, *query); t.Created = ExecSql(DatabaseName, query); return t; }
bool USQLiteDatabase::CreateIndex(const FString DatabaseName, const FString TableName, const FSQLiteIndex Index) { bool idxCrSts = true; FString query = Index.ResultStr.Replace(TEXT("$$$TABLE_NAME$$$"), *TableName); //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); return idxCrSts; }
bool USQLiteDatabase::DropIndex(const FString DatabaseName, const FString IndexName) { bool idxCrSts = true; FString query = "DROP INDEX " + IndexName; //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); return idxCrSts; }
bool USQLiteDatabase::DropTable(const FString DatabaseName, const FString TableName) { bool idxCrSts = true; FString query = "DROP TABLE " + TableName; //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); return idxCrSts; }
bool USQLiteDatabase::TruncateTable(const FString DatabaseName, const FString TableName) { bool idxCrSts = true; FString query = "DELETE FROM " + TableName + ";"; //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); return idxCrSts; }
bool USQLiteDatabase::Vacuum(const FString DatabaseName) { bool idxCrSts = true; FString query = "VACUUM; "; //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); return idxCrSts; }
bool USQLiteDatabase::CreateIndexes(const FString DatabaseName, const FString TableName, const TArray<FSQLiteIndex> Indexes) { bool idxCrSts = true; for (const FSQLiteIndex& idx : Indexes) { if (idx.ResultStr.Len() > 2) { FString query = idx.ResultStr.Replace(TEXT("$$$TABLE_NAME$$$"), *TableName); //LOGSQLITE(Warning, *query); idxCrSts = ExecSql(DatabaseName, query); if (!idxCrSts) { //LOGSQLITE(Warning, TEXT("ExecSql break")); break; } } } return idxCrSts; }
void ConfDb::OpenDb(const string& dbFile, bool needInit) { sqlite3_open(dbFile.c_str(), &mDbConn); SetupPragma(); if (needInit) { ExecSql(SQL_CREATE_TABLE_CONF); Begin(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_X, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_Y, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_WIDTH, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_HEIGHT, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_STR, KEY_LAST_OPEN_PATH, ""); ExecSql(); Commit(); } }
static void MdbSqlCmdFunc(CCmdSession* pSession, const char *sCmdLine, const char* sCmdArg) { if(!bStarted) goto execute; pSession->ForbidSave(true); loop: GetMdbSecurityInfo(); if(!oMdbDsn.Compare("TRUE")) { if(!oMdbUser.Empty() && !oMdbPasswd.Empty()) { pSession->Print("Check your MDB system security information for the '%s'.\r\n", CFilePathInfo::GetInstance()->GetName()); pSession->Print("Please input your name(max 8 character):"); pSession->SetMaxRead(8); const char* s = pSession->ReadLine(false); if(oMdbUser.Compare(s)) { pSession->Print("Sorry, your name is invalid!\r\n"); pSession->SetMaxRead(0); pSession->ForbidSave(false); return; } pSession->Print("Please input your password(max 8 character):"); pSession->SetHidden(true); s = pSession->ReadLine(false); pSession->SetHidden(false); pSession->SetMaxRead(0); if(oMdbPasswd.Compare(s)) { pSession->Print("Sorry, your password is invalid!\r\n"); pSession->ForbidSave(false); return; } } } else if(!oMdbDsn.Compare("FORBID")) { if(!AllowSetMdbSecurityInfo()) { pSession->Print("Sorry, this MDB system forbids telnet!\r\n"); pSession->ForbidSave(false); return; } pSession->Print("Initialize your MDB system security information for '%s'.\r\n", CFilePathInfo::GetInstance()->GetName()); pSession->Print("Please input your name(max 8 character):"); pSession->SetMaxRead(8); const char* s = pSession->ReadLine(false); CString oUser(s); oUser.Trim(); if(oUser.Empty() || oUser.GetSize() > 8) { pSession->Print("Sorry, your name is invalid!\r\n"); pSession->SetMaxRead(0); pSession->ForbidSave(false); return; } pSession->Print("Please input your password(max 8 character):"); pSession->SetHidden(true); s = pSession->ReadLine(false); pSession->SetHidden(false); pSession->SetMaxRead(0); CString oPasswd(s); oPasswd.Trim(); if(oPasswd.Empty() || oPasswd.GetSize() > 8) { pSession->Print("Sorry, your password is invalid!\r\n"); pSession->ForbidSave(false); return; } InitializeMdbSecurityInfo(oUser, oPasswd); goto loop; } pSession->ForbidSave(false); execute: CHistoryCmd *pLocalCmd = new CHistoryCmd, *pOldCmd; CSqlTerminal oSqlTerm = {pSession, SqlPuts, SqlGets, GetSqlBufferSize}; void* pSqlEnv = CreateSqlEnv(&oSqlTerm); pSession->Print("Welcome to the mdb sql environment.\r\n" "You can use the command 'help;' to get the sql usage information.\r\n\r\n"); CCmdSession::SetSession(pSession); pOldCmd = pSession->GetHistoryCmd(); pSession->SetHistoryCmd(pLocalCmd); ExecSql(pSqlEnv); pSession->SetHistoryCmd(pOldCmd); delete pLocalCmd; pSession->Print("Mdb say goodbye to you.\r\n\r\n"); DestroySqlEnv(pSqlEnv); CCmdSession::SetSession(NULL); }
bool CDatabase::EmptyTable(const char* tablename) { return SQLERROR!=ExecSql("delete from %Q;",tablename); }
bool CDatabase::RollBack() { return SQLERROR != ExecSql("rollback transaction"); }
bool CDatabase::Commit() { return SQLERROR != ExecSql("commit transaction;"); }
bool CDatabase::BeginTransaction() { return SQLERROR != ExecSql("begin transaction;"); }
bool CDatabase::DeleteTable(const char* tablename) { return SQLERROR != ExecSql("DROP TABLE %q;",tablename); }
// heart beat to oracle-db. int OracleDB::HB() { const string hbsql = "select sysdate from dual"; return ExecSql(hbsql, 0); }