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


C++ SQLStatement类代码示例

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


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

示例1: SQLStatement

SQLStatement* SqliteStatementCache::InternalGetStatement(const char* func_name,
														 int func_number, const char* sql)
{
	FuncID id;
	id.name = func_name;
	id.number = func_number;

	StatementMap::const_iterator found = statements_.find(id);
	if (found != statements_.end())
		return found->second;

	if (!sql)
		return NULL;  // Don't create a new statement when we were not given SQL.

	// Create a new statement.
	SQLStatement* statement = new SQLStatement();
	if (statement->prepare(db_, sql) != SQLITE_OK)
	{
		const char* err_msg = sqlite3_errmsg(db_);		
		return NULL;
	}

	statements_[id] = statement;
	return statement;
}
开发者ID:niuwei,项目名称:PirateBall,代码行数:25,代码来源:sqlite_compiled_statement.cpp

示例2: temp

void
Repeater::do_load()
{
    SQLStatement statement
    (   database_connection(),
        "select interval_units, interval_type_id, next_date, journal_id "
        "from repeaters where repeater_id = :p"
    );
    statement.bind(":p", id());
    statement.step();
    Repeater temp(*this);
    temp.m_data->frequency = Frequency
    (   statement.extract<int>(0),
        static_cast<IntervalType>(statement.extract<int>(1))
    );
    temp.m_data->next_date =
        numeric_cast<DateRep>(statement.extract<long long>(2));
    temp.m_data->journal_id = statement.extract<Id>(3);
    swap(temp);
    JEWEL_ASSERT
    (   is_valid_date_for_interval_type
        (   boost_date_from_julian_int(value(m_data->next_date)),
            value(m_data->frequency).step_type()
        )
    );
    return;
}
开发者ID:matt-harvey,项目名称:dailycashmanager,代码行数:27,代码来源:repeater.cpp

示例3:

   bool
   PersistentSecurityRange::Exists(const String &name)
   {
      String whereClause = "rangename = '" + SQLStatement::Escape(name) + "'";

      SQLStatement oStatement;
      oStatement.SetStatementType(SQLStatement::STSelect);
      oStatement.SetTable("hm_securityranges");
      oStatement.AddColumn("count(*) as c");
      oStatement.SetWhereClause(whereClause);

      shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(oStatement);
      if (!pRS)
         return false;

      bool bRetVal = false;
      if (!pRS->IsEOF())
      {
         int count = pRS->GetLongValue("c");
         if (count > 0)
            return true;
      }

      return false;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:25,代码来源:PersistentSecurityRange.cpp

示例4: deliverStatementCallback

void SQLTransaction::deliverStatementCallback()
{
    // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback
    // Otherwise, continue to loop through the statement queue
    m_executeSqlAllowed = true;

    SQLStatement* currentStatement = m_backend->currentStatement();
    ASSERT(currentStatement);

    bool result = currentStatement->performCallback(this);

    m_executeSqlAllowed = false;

    if (result) {
        m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "the statement callback raised an exception or statement error callback did not return false");

        if (m_errorCallbackWrapper.hasCallback())
            return deliverTransactionErrorCallback();

        // No error callback, so fast-forward to:
        // Transaction Step 11 - Rollback the transaction.
        m_backend->requestTransitToState(SQLTransactionState::CleanupAfterTransactionErrorCallback);
        return;
    }

    m_backend->requestTransitToState(SQLTransactionState::RunStatements);
}
开发者ID:nickooms,项目名称:webkit,代码行数:27,代码来源:SQLTransaction.cpp

示例5: Instance

   /*
      Delete metadata info for messages no longer in the system.
   */
   bool 
   PersistentMessageMetaData::DeleteOrphanedItems()
   {
      SQLStatement statement;
      statement.SetTable("hm_message_metadata");
      statement.SetStatementType(SQLStatement::STDelete);
      statement.SetWhereClause("not exists (select messageid from hm_messages where messageid = metadata_messageid)");;

      return Application::Instance()->GetDBManager()->Execute(statement);
   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:13,代码来源:PersistentMessageMetaData.cpp

示例6:

   bool
   PersistentFetchAccountUID::SaveObject(shared_ptr<FetchAccountUID> pUID, String &result)
   {
      SQLStatement oStatement;

      oStatement.SetTable("hm_fetchaccounts_uids");

      oStatement.AddColumnInt64("uidfaid", pUID->GetAccountID());
      oStatement.AddColumn("uidvalue", pUID->GetUID());
      oStatement.AddColumnDate("uidtime", pUID->GetCreationDate());

      if (pUID->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("uidid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);
         oStatement.SetWhereClause(Formatter::Format("uidid = {0}", pUID->GetID()));
      }

      bool bNewObject = pUID->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pUID->SetID((int) iDBID);

      return bRetVal;

   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:33,代码来源:PersistentFetchAccountUID.cpp

示例7:

   void 
   IPAddressSQLHelper::AppendStatement(SQLStatement &statement, const IPAddress &address, const AnsiString &address1Column, const AnsiString &address2Column) const
   {
      statement.AddColumnInt64(address1Column, address.GetAddress1());
      
      if (address.GetType() == IPAddress::IPV6)
         statement.AddColumnInt64(address2Column, address.GetAddress2());
      else
         statement.AddColumnNULL(address2Column);

   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:11,代码来源:IPAddressSQLHelper.cpp

示例8: ReadObject

   bool
   PersistentAlias::ReadObject(std::shared_ptr<Alias> pAlias, const String & sName)
   {
      SQLStatement statement;

      statement.SetStatementType(SQLStatement::STSelect);
      statement.SetTable("hm_aliases");
      statement.AddWhereClauseColumn("aliasname", sName);

      return ReadObject(pAlias, statement.GetCommand());
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:11,代码来源:PersistentAlias.cpp

示例9: ReadObject

   bool
   PersistentDistributionList::ReadObject(std::shared_ptr<DistributionList> pDistList, const String &sAddress)
   {
      SQLStatement statement;

      statement.SetStatementType(SQLStatement::STSelect);
      statement.SetTable("hm_distributionlists");
      statement.AddWhereClauseColumn("distributionlistaddress", sAddress);

      return ReadObject(pDistList, statement.GetCommand());
   }  
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:11,代码来源:PersistentDistributionList.cpp

示例10: ReadObject

bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, const String & sAddress)
{
    SQLStatement statement;
    statement.SetStatementType(SQLStatement::STSelect);
    statement.SetTable("hm_accounts");
    statement.AddWhereClauseColumn("accountaddress", sAddress);

    bool bResult = ReadObject(pAccount, statement.GetCommand());

    return bResult;

}
开发者ID:nberardi,项目名称:hMailServer,代码行数:13,代码来源:PersistentAccount.cpp

示例11:

   bool
   PersistentRouteAddress::SaveObject(shared_ptr<RouteAddress> pRA)
   {

      SQLStatement oStatement;
      oStatement.AddColumnInt64("routeaddressrouteid", pRA->GetRouteID());
      oStatement.AddColumn("routeaddressaddress", pRA->GetAddress());

      oStatement.SetTable("hm_routeaddresses");

      if (pRA->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("routeaddressid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);

         String sWhere;
         sWhere.Format(_T("routeaddressid = %I64d"), pRA->GetID());
         oStatement.SetWhereClause(sWhere);
      }

      bool bNewObject = pRA->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pRA->SetID((int) iDBID);

      return bRetVal;
   }
开发者ID:jrallo,项目名称:hMailServer,代码行数:34,代码来源:PersistentRouteAddress.cpp

示例12:

   bool 
   PersistentBlockedAttachment::SaveObject(shared_ptr<BlockedAttachment> pObject)
   {
      SQLStatement oStatement;
      oStatement.SetTable("hm_blocked_attachments");
      
      if (pObject->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("baid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);
         String sWhere;
         sWhere.Format(_T("baid = %I64d"), pObject->GetID());
         oStatement.SetWhereClause(sWhere);
         
      }

      oStatement.AddColumn(_T("bawildcard"), pObject->GetWildcard());
      oStatement.AddColumn(_T("badescription"), pObject->GetDescription());

      bool bNewObject = pObject->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pObject->SetID((int) iDBID);


      return true;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:34,代码来源:PersistentBlockedAttachment.cpp

示例13: Instance

   bool 
   PersistentLogonFailure::AddFailure(const IPAddress &ipaddress)
   {
      SQLStatement statement;

      IPAddressSQLHelper helper;
      helper.AppendStatement(statement, ipaddress, "ipaddress1", "ipaddress2");

      statement.AddColumnCommand("failuretime", SQLStatement::GetCurrentTimestamp());
      statement.SetStatementType(SQLStatement::STInsert);
      statement.SetTable("hm_logon_failures");

      return Application::Instance()->GetDBManager()->Execute(statement);
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:14,代码来源:PersistentLogonFailure.cpp

示例14: BOOST_LOG_FUNCTION

void SQLCode::_BuildSQLStatement(SQLVarParms& varParms, SQLStatement& rSqlStatement)
{
	BOOST_LOG_FUNCTION();
	std::string strSQLKey;
	SQLStatement SQLFormats;
	int nDbType = 0;
	size_t uiTotalSQLSize = 0;	

	try
	{
		size_t uVarCount = varParms.size();
		if (uVarCount < 1)
		{
			throw DataAccessException(ER_DB_ERR_SQLCode, "the PrepareStatement parameter count error!");
		}

		_GetDbTypeAndSQLKey(varParms, strSQLKey);//strSQLID=strSQLKey=varParms[0]
		_GetSQLFormat(strSQLKey, SQLFormats);

		_BuildNormalSQL(varParms, SQLFormats, rSqlStatement);
		rSqlStatement.logInfo();
	}
	catch (DataAccessException& e)
	{
		throw e;
	}
	catch (...)
	{
		throw DataAccessException(ER_DB_ERR_UNKNOWN, "buildSQLStatement error!");
	}

}
开发者ID:lslProjectOrg,项目名称:Projects,代码行数:32,代码来源:SQLCode.cpp

示例15: id

void
Repeater::do_save_existing()
{
    SQLStatement updater
    (   database_connection(),
        "update repeaters set "
        "interval_units = :interval_units, "
        "interval_type_id = :interval_type_id, "
        "next_date = :next_date, "
        "journal_id = :journal_id "
        "where repeater_id = :repeater_id"
    );
    updater.bind(":repeater_id", id());
    process_saving_statement(updater);
    return;
}
开发者ID:matt-harvey,项目名称:dailycashmanager,代码行数:16,代码来源:repeater.cpp


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