本文整理汇总了C++中DB::execQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ DB::execQuery方法的具体用法?C++ DB::execQuery怎么用?C++ DB::execQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::execQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Exception
optional<size_t> TimetableRowTableSync::GetMaxRank( util::RegistryKeyType timetableId )
{
DB* db = DBModule::GetDB();
stringstream query;
// Content
query
<< "SELECT MAX(" << COL_RANK << ") AS mr "
<< " FROM " << TABLE.NAME
<< " WHERE " << COL_TIMETABLE_ID << "=" << timetableId
;
try
{
DBResultSPtr rows = db->execQuery(query.str());
while (rows->next ())
{
return rows->getOptionalUnsignedInt("mr");
}
return optional<size_t>();
}
catch(DBException& e)
{
throw Exception(e.getMessage());
}
}
示例2: _InitAutoIncrement
static void _InitAutoIncrement()
{
if (!K::TABLE.HAS_AUTO_INCREMENT)
return;
try
{
DB* db = DBModule::GetDB();
std::stringstream query;
query <<
"SELECT " << 0x00000000FFFFFFFFLL <<
" & " << TABLE_COL_ID << " AS maxid FROM " << K::TABLE.NAME <<
" WHERE " << TABLE_COL_ID << ">=" << encodeUId(0) << " AND " <<
TABLE_COL_ID << "<=" << encodeUId(0xFFFFFFFF) <<
" ORDER BY " << TABLE_COL_ID << " DESC LIMIT 1"
;
DBResultSPtr result (db->execQuery(query.str()));
if (result->next ())
{
util::RegistryKeyType maxid = result->getLongLong("maxid");
if (maxid > 0)
{
_autoIncrementValue = util::decodeObjectId(maxid) + 1;
util::Log::GetInstance().debug("Auto-increment of table "+ K::TABLE.NAME +" initialized at "+ boost::lexical_cast<std::string>(_autoIncrementValue));
}
}
}
catch (DBException& e)
{
util::Log::GetInstance().debug("Table "+ K::TABLE.NAME +" without preceding id.", e);
}
catch (...)
{
// Log::GetInstance().debug("Table "+ getTableName() +" without preceding id.", e);
}
}