本文整理汇总了C++中NdbConnection::commitStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::commitStatus方法的具体用法?C++ NdbConnection::commitStatus怎么用?C++ NdbConnection::commitStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbConnection
的用法示例。
在下文中一共展示了NdbConnection::commitStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
int optind = 0, i;
if(getarg(args, num_args, argc, argv, &optind) || argv[optind] == NULL) {
arg_printusage(args, num_args, argv[0], "table name\n");
return NDBT_WRONGARGS;
}
// Check if table name is supplied
if (argv[optind] != NULL)
_tableName = argv[optind];
const NdbDictionary::Table* table = NDBT_Tables::getTable(_tableName);
// const NDBT_Attribute* attribute = table->getAttribute(_column);
g_info << "Table " << _tableName << endl
<< "Row: " << _row << ", PrimaryKey: " << _primaryKey
<< endl;
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb* ndb = new Ndb(&con, "TEST_DB");
if (ndb->init() == 0 && ndb->waitUntilReady(30) == 0)
{
NdbConnection* conn = ndb->startTransaction();
if (conn == NULL)
{
g_info << "ERROR: " << ndb->getNdbError() << endl;
delete ndb;
return -1;
}
NdbOperation* op = conn->getNdbOperation(_tableName);
if (op == NULL)
{
g_info << "ERROR: " << conn->getNdbError() << endl;
delete ndb;
return -1;
}
op->readTuple();
NdbRecAttr** data = new NdbRecAttr*[table->getNoOfColumns()];
for (i = 0; i < table->getNoOfColumns(); i++)
{
const NdbDictionary::Column* c = table->getColumn(i);
if (c->getPrimaryKey())
{
op->equal(c->getName(), _primaryKey);
data[i] = op->getValue(c->getName(), NULL);
}
else
{
data[i] = op->getValue(c->getName(), NULL);
}
}
if (conn->execute(Commit) == 0)
{
// Print column names
for (i = 0; i < table->getNoOfColumns(); i++)
{
const NdbDictionary::Column* c = table->getColumn(i);
g_info
<< c->getName()
<< "[" << c->getType() << "] ";
}
g_info << endl;
if (_hex)
{
g_info << hex;
}
for (i = 0; i < table->getNoOfColumns(); i++)
{
NdbRecAttr* a = data[i];
ndbout << (* a) << " ";
} // for
g_info << endl;
} // if (conn
else
{
g_info << "Failed to commit read transaction... "
<< conn->getNdbError()
<< ", commitStatus = " << conn->commitStatus()
<< endl;
}
delete[] data;
ndb->closeTransaction(conn);
} // if (ndb.init
else
{
g_info << "ERROR: Unable to connect to NDB, "
<< ndb->getNdbError() << endl;
}
delete ndb;
return 0;
}