当前位置: 首页>>代码示例>>C++>>正文


C++ PrepareStatement函数代码示例

本文整理汇总了C++中PrepareStatement函数的典型用法代码示例。如果您正苦于以下问题:C++ PrepareStatement函数的具体用法?C++ PrepareStatement怎么用?C++ PrepareStatement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PrepareStatement函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: enter

int FbDatabase::NewId(const int iParam, int iIncrement)
{
	wxCriticalSectionLocker enter(sm_queue);

	const wchar_t * table = iParam < 100 ? wxT("params") : wxT("config");

	int iValue = 0;
	{
		wxString sql = wxString::Format(wxT("SELECT value FROM %s WHERE id=?"), table);
		FbSQLite3Statement stmt = PrepareStatement(sql);
		stmt.Bind(1, iParam);
		FbSQLite3ResultSet result = stmt.ExecuteQuery();
		if (result.NextRow()) iValue = result.GetInt(0);
	}

	if (iIncrement) {
		iValue += iIncrement;
		wxString sql = wxString::Format(wxT("INSERT OR REPLACE INTO %s(value,id)VALUES(?,?)"), table);
		FbSQLite3Statement stmt = PrepareStatement(sql);
		stmt.Bind(1, iValue);
		stmt.Bind(2, iParam);
		stmt.ExecuteUpdate();
	}

	return iValue;
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:26,代码来源:FbDatabase.cpp

示例2: PrepareInsertStatement

bool CQueueStorage::Impl::PrepareStatements()
{
	if (!db_)
		return false;

	insertServerQuery_ = PrepareInsertStatement(_T("servers"), server_table_columns, sizeof(server_table_columns) / sizeof(_column));
	insertFileQuery_ = PrepareInsertStatement(_T("files"), file_table_columns, sizeof(file_table_columns) / sizeof(_column));
	insertLocalPathQuery_ = PrepareInsertStatement(_T("local_paths"), path_table_columns, sizeof(path_table_columns) / sizeof(_column));
	insertRemotePathQuery_ = PrepareInsertStatement(_T("remote_paths"), path_table_columns, sizeof(path_table_columns) / sizeof(_column));
	if (!insertServerQuery_ || !insertFileQuery_ || !insertLocalPathQuery_ || !insertRemotePathQuery_)
		return false;

	{
		wxString query = _T("SELECT ");
		for (unsigned int i = 0; i < (sizeof(server_table_columns) / sizeof(_column)); ++i)
		{
			if (i > 0)
				query += _T(", ");
			query += server_table_columns[i].name;
		}

		query += _T(" FROM servers ORDER BY id ASC");

		if (!(selectServersQuery_ = PrepareStatement(query)))
			return false;
	}

	{
		wxString query = _T("SELECT ");
		for (unsigned int i = 0; i < (sizeof(file_table_columns) / sizeof(_column)); ++i)
		{
			if (i > 0)
				query += _T(", ");
			query += file_table_columns[i].name;
		}

		query += _T(" FROM files WHERE server=:server ORDER BY id ASC");

		if (!(selectFilesQuery_ = PrepareStatement(query)))
			return false;
	}

	{
		wxString query = _T("SELECT id, path FROM local_paths");
		if (!(selectLocalPathQuery_ = PrepareStatement(query)))
			return false;
	}

	{
		wxString query = _T("SELECT id, path FROM remote_paths");
		if (!(selectRemotePathQuery_ = PrepareStatement(query)))
			return false;
	}
	return true;
}
开发者ID:juaristi,项目名称:filezilla,代码行数:55,代码来源:queue_storage.cpp

示例3: ResetErrorCodes

wxDatabaseResultSet* wxOdbcDatabase::RunQueryWithResults(const wxString& strQuery)
{
   ResetErrorCodes();

   wxOdbcPreparedStatement* pStatement = (wxOdbcPreparedStatement*)PrepareStatement( strQuery, true );

   if ( pStatement )
   {
     try
     {
       pStatement->SetOneTimer(true);
       wxDatabaseResultSet* pResults = pStatement->RunQueryWithResults(false /*false for "Don't log this result set for cleanup*/);
       LogResultSetForCleanup(pResults);
       return pResults;
     }
     catch (...)
     {
       SetErrorCode(pStatement->GetErrorCode());
       SetErrorMessage(pStatement->GetErrorMessage());
       wxDELETE( pStatement );
       ThrowDatabaseException();
       return NULL;
     }
   }
   else
     return NULL;
}
开发者ID:mtangoo,项目名称:wxDatabase,代码行数:27,代码来源:odbc_database.cpp

示例4: PrepareStatement

int FbDatabase::Int(const wxString & id, const wxString & sql, int null)
{
	FbSQLite3Statement stmt = PrepareStatement(sql + wxT(" LIMIT 1"));
	stmt.Bind(1, id);
	FbSQLite3ResultSet result = stmt.ExecuteQuery();
	return result.NextRow() ? result.GetInt(0, null) : null;
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:7,代码来源:FbDatabase.cpp

示例5: LOG_TRACE

ResultType TrafficCop::ExecuteStatement(
    const std::string &query, std::vector<StatementResult> &result,
    std::vector<FieldInfo> &tuple_descriptor, int &rows_changed,
    std::string &error_message,
    const size_t thread_id UNUSED_ATTRIBUTE) {
  LOG_TRACE("Received %s", query.c_str());

  // Prepare the statement
  std::string unnamed_statement = "unnamed";
  auto statement = PrepareStatement(unnamed_statement, query, error_message);

  if (statement.get() == nullptr) {
    return ResultType::FAILURE;
  }

  // Then, execute the statement
  bool unnamed = true;
  std::vector<int> result_format(statement->GetTupleDescriptor().size(), 0);
  std::vector<type::Value> params;
  auto status =
      ExecuteStatement(statement, params, unnamed, nullptr, result_format,
                       result, rows_changed, error_message, thread_id);

  if (status == ResultType::SUCCESS) {
    LOG_TRACE("Execution succeeded!");
    tuple_descriptor = std::move(statement->GetTupleDescriptor());
  } else {
    LOG_TRACE("Execution failed!");
  }

  return status;
}
开发者ID:Michael-Tieying-Zhang,项目名称:peloton,代码行数:32,代码来源:tcop.cpp

示例6: definitions

/*!
  \brief Load data block definitions (&B)

  Call VFKReader::OpenFile() before this function.

  \return number of data blocks or -1 on error
*/
int VFKReaderSQLite::ReadDataBlocks()
{
    int  nDataBlocks = -1;
    CPLString osSQL;
    const char *pszName, *pszDefn;
    IVFKDataBlock *poNewDataBlock;

    sqlite3_stmt *hStmt;

    osSQL.Printf("SELECT table_name, table_defn FROM %s", VFK_DB_TABLE);
    hStmt = PrepareStatement(osSQL.c_str());
    while(ExecuteSQL(hStmt) == OGRERR_NONE) {
        pszName = (const char*) sqlite3_column_text(hStmt, 0);
        pszDefn = (const char*) sqlite3_column_text(hStmt, 1);
        poNewDataBlock = (IVFKDataBlock *) CreateDataBlock(pszName);
        poNewDataBlock->SetGeometryType();
        poNewDataBlock->SetProperties(pszDefn);
        VFKReader::AddDataBlock(poNewDataBlock, NULL);
    }

    if (m_nDataBlockCount == 0) {
        CPL_IGNORE_RET_VAL(sqlite3_exec(m_poDB, "BEGIN", NULL, NULL, NULL));
        /* CREATE TABLE ... */
        nDataBlocks = VFKReader::ReadDataBlocks();
        CPL_IGNORE_RET_VAL(sqlite3_exec(m_poDB, "COMMIT", NULL, NULL, NULL));

        StoreInfo2DB();
    }

    return nDataBlocks;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:38,代码来源:vfkreadersqlite.cpp

示例7: DoPrepareStatements

bool MySQLConnection::PrepareStatements()
{
    DoPrepareStatements();
    for (PreparedStatementMap::const_iterator itr = m_queries.begin(); itr != m_queries.end(); ++itr)
        PrepareStatement(itr->first, itr->second.first, itr->second.second);
    return !m_prepareError;
}
开发者ID:FirstCore,项目名称:GaryMoveOut_4.3.4,代码行数:7,代码来源:MySQLConnection.cpp

示例8: wxT

void FbDatabase::AttachConfig()
{
	wxString sql = wxT("ATTACH ? AS config");
	FbSQLite3Statement stmt = PrepareStatement(sql);
	stmt.Bind(1, GetConfigName());
	stmt.ExecuteUpdate();
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:7,代码来源:FbDatabase.cpp

示例9: SetCollation

void FbDatabase::AttachCommon()
{
	SetCollation(wxT("CYR"), &sm_collation);
	wxString sql = wxT("ATTACH ? AS config");
	FbSQLite3Statement stmt = PrepareStatement(sql);
	stmt.Bind(1, wxGetApp().GetLibFile());
	stmt.ExecuteUpdate();
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:8,代码来源:FbDatabase.cpp

示例10: nowarn

void CRUSQLDynamicStatementContainer::PrepareSQL()
{
	for (Int32 i=0; i < GetNumOfStmt(); i++)
	{
#pragma nowarn(1506)   // warning elimination 
		PrepareStatement(i);
#pragma warn(1506)  // warning elimination 
	}
}
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:9,代码来源:RuSQLDynamicStatementContainer.cpp

示例11: GetPreparedStatement

CDMPreparedStatement *CRUSQLDynamicStatementContainer::DynamicStmt::
	GetPreparedStatement(BOOL DeleteUsedStmt) 
{
	if (FALSE == prepared_)
	{
		PrepareStatement(DeleteUsedStmt);
	}

	return inherited::GetPreparedStatement();
}
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:10,代码来源:RuSQLDynamicStatementContainer.cpp

示例12: ResetErrorCodes

DatabaseResultSet* SqliteDatabaseLayer::RunQueryWithResults(const wxString& strQuery)
{
  ResetErrorCodes();

  if (m_pDatabase != NULL)
  {
    wxArrayString QueryArray = ParseQueries(strQuery);
     
    for (unsigned int i=0; i<(QueryArray.size()-1); i++)
    {
      char* szErrorMessage = NULL;
      wxString strErrorMessage = _("");
      wxCharBuffer sqlBuffer = ConvertToUnicodeStream(QueryArray[i]);
      int nReturn = sqlite3_exec((sqlite3*)m_pDatabase, sqlBuffer, 0, 0, &szErrorMessage);
  
      if (szErrorMessage != NULL)
      {
        SetErrorCode(SqliteDatabaseLayer::TranslateErrorCode(sqlite3_errcode((sqlite3*)m_pDatabase)));
        strErrorMessage = ConvertFromUnicodeStream(szErrorMessage);
        sqlite3_free(szErrorMessage);
        return NULL;
      }

      if (nReturn != SQLITE_OK)
      {
        SetErrorCode(SqliteDatabaseLayer::TranslateErrorCode(sqlite3_errcode((sqlite3*)m_pDatabase)));
        SetErrorMessage(strErrorMessage);
        ThrowDatabaseException();
        return NULL;
      }
    }

    // Create a Prepared statement for the last SQL statement and get a result set from it
    SqlitePreparedStatement* pStatement = (SqlitePreparedStatement*)PrepareStatement(QueryArray[QueryArray.size()-1], false);
    SqliteResultSet* pResultSet = new SqliteResultSet(pStatement, true);
    if (pResultSet)
      pResultSet->SetEncoding(GetEncoding());

    LogResultSetForCleanup(pResultSet);
    return pResultSet;
  }
  else
  {
    return NULL;
  }
}
开发者ID:AndrianDTR,项目名称:Inventory,代码行数:46,代码来源:SqliteDatabaseLayer.cpp

示例13: VFKDataBlock

/*!
  \brief Create DB table from VFKDataBlock (SQLITE only)

  \param poDataBlock pointer to VFKDataBlock instance
*/
void VFKReaderSQLite::AddDataBlock(IVFKDataBlock *poDataBlock, const char *pszDefn)
{
    CPLString osCommand, osColumn;
    
    VFKPropertyDefn *poPropertyDefn;
    
    sqlite3_stmt *hStmt;

    /* register table in 'vfk_blocks' */
    osCommand.Printf("SELECT COUNT(*) FROM vfk_blocks WHERE "
                     "table_name = '%s'",
                     poDataBlock->GetName());
    hStmt = PrepareStatement(osCommand.c_str());
    if (ExecuteSQL(hStmt) == OGRERR_NONE &&
        sqlite3_column_int(hStmt, 0) == 0) {
        
        osCommand.Printf("CREATE TABLE '%s' (", poDataBlock->GetName());
        for (int i = 0; i < poDataBlock->GetPropertyCount(); i++) {
            poPropertyDefn = poDataBlock->GetProperty(i);
            if (i > 0)
                osCommand += ",";
            osColumn.Printf("%s %s", poPropertyDefn->GetName(),
                            poPropertyDefn->GetTypeSQL().c_str());
            osCommand += osColumn;
        }
        osColumn.Printf(",%s integer", FID_COLUMN);
	osCommand += osColumn;
	if (poDataBlock->GetGeometryType() != wkbNone) {
	    osColumn.Printf(",%s blob", GEOM_COLUMN);
            osCommand += osColumn;
	}
	osCommand += ")";
        ExecuteSQL(osCommand.c_str()); /* CREATE TABLE */
        
        osCommand.Printf("INSERT INTO 'vfk_blocks' (file_name, table_name, "
                         "num_records, num_geometries, table_defn) VALUES "
			 "('%s', '%s', -1, 0, '%s')",
			 m_pszFilename, poDataBlock->GetName(), pszDefn);
	
        ExecuteSQL(osCommand.c_str());

        sqlite3_finalize(hStmt);
    }
        
    return VFKReader::AddDataBlock(poDataBlock, NULL);
}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:51,代码来源:vfkreadersqlite.cpp

示例14: PrepareStatement

bool CharacterDatabaseConnection::Open()
{
    if (!MySQLConnection::Open())
        return false;

    if (!m_reconnecting)
        m_stmts.resize(MAX_CHARACTERDATABASE_STATEMENTS);

    for (uint32 index = 0; index < MAX_CHARACTERDATABASE_STATEMENTS; ++index)
    {
        PreparedStatementTable const& pst = CharacterDatabasePreparedStatements[index];        
        PrepareStatement(pst.index, pst.query, pst.type);
    }

    m_statementTable = CharacterDatabasePreparedStatements;

    return true;
}
开发者ID:1024wow,项目名称:TrinityCore,代码行数:18,代码来源:CharacterDatabase.cpp

示例15: PrepareStatement

bool WorldDatabaseConnection::Open()
{
    if (!MySQLConnection::Open())
        return false;

    m_stmts.resize(MAX_WORLDDATABASE_STATEMENTS);

    /*
        ##################################
        LOAD YOUR PREPARED STATEMENTS HERE
        ##################################
    */
    PrepareStatement(WORLD_DEL_CRESPAWNTIME, "DELETE FROM creature_respawn WHERE guid = ? AND instance = ?");
    PrepareStatement(WORLD_ADD_CRESPAWNTIME, "INSERT INTO creature_respawn VALUES (?, ?, ?)");
    PrepareStatement(WORLD_LOAD_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest");
    PrepareStatement(WORLD_DEL_CRELINKED_RESPAWN, "DELETE FROM creature_linked_respawn WHERE guid = ?");
    PrepareStatement(WORLD_REP_CRELINKED_RESPAWN, "REPLACE INTO creature_linked_respawn (guid,linkedGuid) VALUES (?, ?)");
    PrepareStatement(WORLD_DEL_GAMEOBJECT_RESPAWN_TIMES, "DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
    PrepareStatement(WORLD_LOAD_CRETEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound FROM creature_text");
    PrepareStatement(WORLD_LOAD_SMART_SCRIPTS,  "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_x, target_y, target_z, target_o FROM smart_scripts");
    PrepareStatement(WORLD_LOAD_SMARTAI_WP,  "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid");

    return true;
}
开发者ID:mmihail,项目名称:trinitycore10353,代码行数:24,代码来源:WorldDatabase.cpp


注:本文中的PrepareStatement函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。