本文整理汇总了C++中db::Result::getDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ Result::getDouble方法的具体用法?C++ Result::getDouble怎么用?C++ Result::getDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db::Result
的用法示例。
在下文中一共展示了Result::getDouble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: can_update_real_attribute_bound_value
void test_a_db_with_a_connection_with_tables::can_update_real_attribute_bound_value()
{
// insert new object
DB::Statement statement = connection->prepare(
"insert into object default values");
CPPUNIT_ASSERT(statement.isValid());
CPPUNIT_ASSERT(connection->execute(statement));
long long object_id = connection->lastInsertRowId();
CPPUNIT_ASSERT(object_id != 0);
// insert real value
statement = connection->prepare(
"insert into attribute_real (value,type,object_id) values(%f,%d,%lld)",
1.238,
1238,
object_id);
CPPUNIT_ASSERT(statement.isValid());
CPPUNIT_ASSERT(connection->execute(statement));
// prepare update real attribute statement
statement = connection->prepare(
"update attribute_real set value=? where type=%d and object_id=%lld",
1238,
object_id);
CPPUNIT_ASSERT(statement.isValid());
// Bind 3333.3333 to the first parameter
CPPUNIT_ASSERT(DB::Bindings(statement).bindDouble(1,3333.3333));
// Execute the statement to update the attribute value
CPPUNIT_ASSERT(connection->execute(statement));
// Retrieve the double value from the attribute
statement = connection->prepare(
"select value from attribute_real as t where t.type=%d and t.object_id=%lld",
1238,
object_id);
CPPUNIT_ASSERT(statement.isValid());
DB::Result result = connection->perform(statement);
CPPUNIT_ASSERT(result.isValid());
// check that the retrieved value matches the original value.
CPPUNIT_ASSERT_DOUBLES_EQUAL(result.getDouble(1), 3333.3333, 0.00001);
}
示例2: supports_transactions_with_other_connections_open
void test_a_db_with_a_connection_with_tables_with_a_second_connection_open::supports_transactions_with_other_connections_open()
{
CPPUNIT_ASSERT(connection2->beginTransactionRO());
supports_transactions();
// Retrieve the double value from the attribute
DB::Statement statement = connection2->prepare(
"select value from attribute_real as t where t.type=%d and t.object_id=%lld",
1238,
connection->lastInsertRowId());
CPPUNIT_ASSERT(statement.isValid());
DB::Result result = connection2->perform(statement);
CPPUNIT_ASSERT(result.isValid());
// check that the retrieved value matches the original value.
CPPUNIT_ASSERT_DOUBLES_EQUAL(result.getDouble(1), 3333.3333, 0.00001);
CPPUNIT_ASSERT(connection2->commitTransaction());
}