本文整理汇总了C++中SQLStatement::SetAdditionalSQL方法的典型用法代码示例。如果您正苦于以下问题:C++ SQLStatement::SetAdditionalSQL方法的具体用法?C++ SQLStatement::SetAdditionalSQL怎么用?C++ SQLStatement::SetAdditionalSQL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLStatement
的用法示例。
在下文中一共展示了SQLStatement::SetAdditionalSQL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: max
// 2011-11-15 JDR: Modified this function to include quickIndex to pick a specific query.
set<boost::shared_ptr<PersistentMessageMetaData::MessageInfo> >
PersistentMessageMetaData::GetMessagesToIndex(bool quickIndex = false)
{
set<boost::shared_ptr<MessageInfo> > result;
SQLStatement statement;
statement.AddColumn("messageid");
statement.AddColumn("messageaccountid");
statement.AddColumn("messagefolderid");
statement.AddColumn("messagefilename");
statement.AddColumn("accountaddress");
statement.SetStatementType(SQLStatement::STSelect);
statement.SetTable("hm_messages");
// Are we doing a quick index?
if (quickIndex == true) {
// 1000 default
int iIndexerQuickLimit = IniFileSettings::Instance()->GetIndexerQuickLimit();
// yes, only pick the last iIndexerQuickLimit records... very quick compared to full
String whereClause;
whereClause.Format(_T("hm_messages.messagetype = 2 AND hm_messages.messageid > (select max(hm_messages.messageid) - %d from hm_messages) AND hm_message_metadata.metadata_id IS NULL"), iIndexerQuickLimit);
statement.SetWhereClause(whereClause);
statement.SetAdditionalSQL("LEFT JOIN hm_accounts ON hm_messages.messageaccountid = hm_accounts.accountid LEFT JOIN hm_message_metadata ON hm_messages.messageid = hm_message_metadata.metadata_messageid ");
LOG_DEBUG("Doing QUICK index...");
} else {
// 25000 default
int iIndexerFullLimit = IniFileSettings::Instance()->GetIndexerFullLimit();
// Otherwise do the old/standard way (pick iIndexerFullLimit records max)
statement.SetWhereClause("messagetype = 2 AND NOT EXISTS (SELECT metadata_messageid FROM hm_message_metadata WHERE hm_messages.messagetype = 2 and hm_messages.messageid = hm_message_metadata.metadata_messageid)");
statement.SetAdditionalSQL("left join hm_accounts on hm_messages.messageaccountid = hm_accounts.accountid");
statement.SetTopRows(iIndexerFullLimit);
LOG_DEBUG("Doing FULL index... ");
}
boost::shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(statement);
if (!pRS)
return result;
while (!pRS->IsEOF())
{
boost::shared_ptr<MessageInfo> messageInfo = boost::shared_ptr<MessageInfo>(new MessageInfo);
messageInfo->MessageID = pRS->GetInt64Value("messageid");
messageInfo->AccountID = pRS->GetLongValue("messageaccountid");
messageInfo->FolderID = pRS->GetLongValue("messagefolderid");
String accountAddress = pRS->GetStringValue("accountaddress");
String fileName = pRS->GetStringValue("messagefilename");
boost::shared_ptr<Message> dummyMessage = boost::shared_ptr<Message>(new Message);
dummyMessage->SetID(messageInfo->MessageID);
dummyMessage->SetAccountID(messageInfo->AccountID);
dummyMessage->SetFolderID(messageInfo->FolderID);
dummyMessage->SetPartialFileName(fileName);
String fullPath = PersistentMessage::GetFileName(accountAddress, dummyMessage);
messageInfo->FileName = fullPath;
result.insert(messageInfo);
pRS->MoveNext();
}
return result;
}