예제 #1
0
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;
}
예제 #2
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);

	}
}
예제 #3
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
void ConfDb::SetWindowY(int y)
{
    FORMAT_SQL(SQL_UPDATE_CONF_INT,
               KEY_WND_Y,
               y,
               KEY_WND_Y);
    ExecSql();
}
예제 #4
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
void ConfDb::SetWindowX(int x)
{
    FORMAT_SQL(SQL_UPDATE_CONF_INT,
               KEY_WND_X,
               x,
               KEY_WND_X);
    ExecSql();
}
예제 #5
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
void ConfDb::SetLastOpenPath(const string& path)
{
    FORMAT_SQL(SQL_UPDATE_CONF_STR,
               KEY_LAST_OPEN_PATH,
               path.c_str(),
               KEY_LAST_OPEN_PATH);
    ExecSql();
}
예제 #6
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
void ConfDb::SetWindowHeight(int h)
{
    FORMAT_SQL(SQL_UPDATE_CONF_INT,
               KEY_WND_HEIGHT,
               h,
               KEY_WND_HEIGHT);
    ExecSql();
}
예제 #7
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
void ConfDb::SetWindowWidth(int w)
{
    FORMAT_SQL(SQL_UPDATE_CONF_INT,
               KEY_WND_WIDTH,
               w,
               KEY_WND_WIDTH);
    ExecSql();
}
예제 #8
0
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;
    }
}
예제 #9
0
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;

}
예제 #10
0
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;

}
예제 #11
0
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;

}
예제 #12
0
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;

}
예제 #13
0
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;

}
예제 #14
0
bool USQLiteDatabase::Vacuum(const FString DatabaseName)
{
	bool idxCrSts = true;


	FString query = "VACUUM; ";

	//LOGSQLITE(Warning, *query);

	idxCrSts = ExecSql(DatabaseName, query);

	return idxCrSts;

}
예제 #15
0
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;

}
예제 #16
0
파일: ConfDb.cpp 프로젝트: bsdelf/cashio
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();
    }
}
예제 #17
0
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);
}
예제 #18
0
	bool CDatabase::EmptyTable(const char* tablename)
	{
		return SQLERROR!=ExecSql("delete from %Q;",tablename);
	}
예제 #19
0
	bool CDatabase::RollBack()
	{
		return SQLERROR != ExecSql("rollback transaction");
	}
예제 #20
0
	bool CDatabase::Commit()
	{
		return SQLERROR != ExecSql("commit transaction;");
	}
예제 #21
0
	bool CDatabase::BeginTransaction()
	{
		return SQLERROR != ExecSql("begin transaction;");
	}
예제 #22
0
	bool CDatabase::DeleteTable(const char* tablename)
	{
		return SQLERROR != ExecSql("DROP TABLE %q;",tablename);
	}
예제 #23
0
파일: oracledb.cpp 프로젝트: gityf/db
// heart beat to oracle-db.
int OracleDB::HB() {
    const string hbsql = "select sysdate from dual";
    return ExecSql(hbsql, 0);
}