我需要帮助C ++ mysqlpp驱动程序调用存储过程并检索其输出参数。查询似乎成功通过但尝试获取存储的值会导致分段错误。我目前的伪代码是:
mysqlpp::Connection* connection; // the connection type I am bound to use, no createStatement, prepareStatement methods
Query query = connection->query();
Query transactionQuery = connection->query();
query << "CALL sp_get_transactions_count(" << inputId << ", @transactionsCount);";
transactionQuery << "SELECT @transactionsCount as combinations;";
ClearQuerySentry cleanUpQuery(transactionQuery);
query.exec();
mysqlpp::StoreQueryResult transactionsResult = transactionQuery.store();
if (!transactionsResult || transactionsResult.num_rows() == 0)
{
logWarning(....);
}
else
{
const mysqlpp::Row& transactionRecord = result[0];
environment.pairTransactionsCount = verboseLexicalCast<int>(transactionRecord, "combinations"); // segfault on trying to cast static_cast<const char*>(row[fieldName.c_str()]))
}
我对mysqlpp和MySQL整体不是很有经验,所以我对解决方案的看法是错误的。提前谢谢。