本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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!");
}
}
示例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;
}