本文整理汇总了C++中NdbConnection类的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection类的具体用法?C++ NdbConnection怎么用?C++ NdbConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NdbConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_part_info
static
void print_part_info(Ndb* pNdb, NDBT_Table* pTab)
{
InfoInfo g_part_info[] = {
{ "Partition", 0, NdbDictionary::Column::FRAGMENT },
{ "Row count", 0, NdbDictionary::Column::ROW_COUNT },
{ "Commit count", 0, NdbDictionary::Column::COMMIT_COUNT },
{ "Frag fixed memory", 0, NdbDictionary::Column::FRAGMENT_FIXED_MEMORY },
{ "Frag varsized memory", 0, NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY },
{ 0, 0, 0 }
};
ndbout << "-- Per partition info -- " << endl;
NdbConnection* pTrans = pNdb->startTransaction();
if (pTrans == 0)
return;
do
{
NdbScanOperation* pOp= pTrans->getNdbScanOperation(pTab->getName());
if (pOp == NULL)
break;
int rs = pOp->readTuples(NdbOperation::LM_CommittedRead);
if (rs != 0)
break;
if (pOp->interpret_exit_last_row() != 0)
break;
Uint32 i = 0;
for(i = 0; g_part_info[i].m_title != 0; i++)
{
if ((g_part_info[i].m_rec_attr = pOp->getValue(g_part_info[i].m_column)) == 0)
break;
}
if (g_part_info[i].m_title != 0)
break;
if (pTrans->execute(NoCommit) != 0)
break;
for (i = 0; g_part_info[i].m_title != 0; i++)
ndbout << g_part_info[i].m_title << "\t";
ndbout << endl;
while(pOp->nextResult() == 0)
{
for(i = 0; g_part_info[i].m_title != 0; i++)
{
ndbout << *g_part_info[i].m_rec_attr << "\t";
}
ndbout << endl;
}
} while(0);
pTrans->close();
}
示例2: start_T1
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
void
start_T1(Ndb * pNDB, ThreadData * td){
DEBUG2("T1(%.*s): - Starting\n", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
int check;
NdbConnection * pCON = pNDB->startTransaction();
if (pCON != NULL) {
NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOp != NULL) {
MyOp->updateTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
pCON->executeAsynchPrepare( Commit , T1_Callback, td);
} else {
CHECK_NULL(MyOp, "T1: getNdbOperation", pCON);
}//if
} else {
error_handler("T1-1: startTranscation",
pNDB->getNdbErrorString(),
pNDB->getNdbError());
}//if
}
示例3: start_T2
/**
* Transaction 2 - T2
*
* Read from Subscriber:
*
* Input:
* SubscriberNumber
*
* Output:
* Location
* Changed by
* Changed Timestamp
* Name
*/
void
start_T2(Ndb * pNDB, ThreadData * td){
DEBUG3("T2(%.*s, %p): - Starting\n", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.location);
int check;
NdbRecAttr * check2;
NdbConnection * pCON = pNDB->startTransaction();
if (pCON == NULL)
error_handler("T2-1: startTransaction",
pNDB->getNdbErrorString(),
pNDB->getNdbError());
NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOp, "T2: getNdbOperation",
pCON);
MyOp->readTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->getValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
MyOp->getValue(IND_SUBSCRIBER_NAME,
td->transactionData.name);
pCON->executeAsynchPrepare( Commit, T2_Callback, td );
}
示例4: DeleteTransaction
int DeleteTransaction(Ndb* pNdb, long iContextId, NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!pNdbOperation->deleteTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId))
{
if(pNdbConnection->execute(Commit) == 0)
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例5: UpdateTransaction
int UpdateTransaction(Ndb* pNdb, long iContextId, NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!pNdbOperation->updateTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
&& !pNdbOperation->setValue(c_szContextData, STATUS_DATA, g_nStatusDataSize))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例6: start_T1
void
start_T1(Ndb * pNDB, ThreadData * td, int async){
DEBUG2("T1(%.*s): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0){
CHECK_ALLOWED_ERROR("T1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOp != NULL) {
MyOp->updateTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
if (async == 1) {
pCON->executeAsynchPrepare( Commit , T1_Callback, td);
} else {
int result = pCON->execute(Commit);
T1_Callback(result, pCON, (void*)td);
return;
}//if
} else {
CHECK_NULL(MyOp, "T1: getNdbOperation", td, pCON->getNdbError());
}//if
}
示例7: T1
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
int
T1(void * obj,
const SubscriberNumber number,
const Location new_location,
const ChangedBy changed_by,
const ChangedTime changed_time,
BenchmarkTime * transaction_time){
Ndb * pNDB = (Ndb *) obj;
DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
BenchmarkTime start;
get_time(&start);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction);
check = MyOperation->updateTuple();
CHECK_MINUS_ONE(check, "T1: updateTuple",
MyTransaction);
check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
CHECK_MINUS_ONE(check, "T1: equal subscriber",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&new_location);
CHECK_MINUS_ONE(check, "T1: setValue location",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
CHECK_MINUS_ONE(check, "T1: setValue changed_by",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
CHECK_MINUS_ONE(check, "T1: setValue changed_time",
MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "T1: Commit",
MyTransaction);
pNDB->closeTransaction(MyTransaction);
get_time(transaction_time);
time_diff(transaction_time, &start);
return 0;
}
示例8: read_and_verify_rows
void read_and_verify_rows(Ndb* pMyNdb, bool pre) {
int check = -1 ;
int loop_count_ops = nRecords;
char expectedCOL1[NUMBEROFRECORDS] = {0} ;
char expectedCOL2[NUMBEROFRECORDS] = {0} ;
NdbConnection *pMyTransaction = NULL ;
NdbOperation *MyOp = NULL ;
NdbRecAttr* tTmp = NULL ;
int readValue[MAXATTR] = {0} ;
ndbout << "Verifying records...\n"<< endl;
for (int count=0 ; count < loop_count_ops ; count++) {
pMyTransaction = pMyNdb->startTransaction();
if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
MyOp = pMyTransaction->getNdbOperation(tableName);
if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
check = MyOp->readTuple();
if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
check = MyOp->equal( attrName[0],(char*)&pkValue[count] );
if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
for (int count_attributes = 1; count_attributes < MAXATTR; count_attributes++) {
tTmp = MyOp->getValue( (char*)attrName[count_attributes], (char*)&readValue[count_attributes] );
if(!tTmp) error_handler( MyOp->getNdbError(), NO_FAIL);
}
if( pMyTransaction->execute( Commit ) == -1 ) {
error_handler(pMyTransaction->getNdbError(), NO_FAIL);
} else {
if (pre) {
expectedCOL1[count] = readValue[1];
expectedCOL2[count] = readValue[2];
}
ndbout << attrName[1] << "\t " << readValue[1] << "\t "
<< attrName[2] << "\t " << readValue[2] << endl;
}
pMyNdb->closeTransaction(pMyTransaction);
}
ndbout << "\nOK\n" << endl;
return;
};
示例9: runPkReadPkUpdateUntilStopped
int runPkReadPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
int records = ctx->getNumRecords();
Ndb* pNdb = GETNDB(step);
int i = 0;
HugoOperations hugoOps(*ctx->getTab());
while (ctx->isTestStopped() == false) {
g_info << i++ << ": ";
int rows = (rand()%records)+1;
int batch = (rand()%rows)+1;
int row = (records - rows) ? rand() % (records - rows) : 0;
int j,k;
for(j = 0; j<rows; j += batch)
{
k = batch;
if(j+k > rows)
k = rows - j;
if(hugoOps.startTransaction(pNdb) != 0)
goto err;
if(hugoOps.pkReadRecord(pNdb, row+j, k, NdbOperation::LM_Exclusive) != 0)
goto err;
if(hugoOps.execute_NoCommit(pNdb) != 0)
goto err;
if(hugoOps.pkUpdateRecord(pNdb, row+j, k, rand()) != 0)
goto err;
if(hugoOps.execute_Commit(pNdb) != 0)
goto err;
if(hugoOps.closeTransaction(pNdb) != 0)
return NDBT_FAILED;
}
continue;
err:
NdbConnection* pCon = hugoOps.getTransaction();
if(pCon == 0)
continue;
NdbError error = pCon->getNdbError();
hugoOps.closeTransaction(pNdb);
if (error.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50);
continue;
}
return NDBT_FAILED;
}
return NDBT_OK;
}
示例10: NdbThreadFuncUpdate
extern "C" void* NdbThreadFuncUpdate(void* pArg)
{
myRandom48Init((long int)NdbTick_CurrentMillisecond());
unsigned nSucc = 0;
unsigned nFail = 0;
Ndb* pNdb = NULL ;
pNdb = new Ndb("TEST_DB");
VerifyMethodInt(pNdb, init());
VerifyMethodInt(pNdb, waitUntilReady());
while(NdbMutex_Trylock(g_pNdbMutex)) {
Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
NdbConnection* pNdbConnection = NULL ;
VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
CHK_TR(pNdbConnection) ; // epaulsa
NdbOperation* pNdbOperationW = NULL ;
VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
VerifyMethodInt(pNdbOperationW, interpretedUpdateTuple());
VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
VerifyMethodInt(pNdbOperationW, incValue(c_szWarehouseCount, Uint32(1)));
Uint32 nWarehouseSum = 0;
for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
NdbOperation* pNdbOperationD = NULL ;
VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
VerifyMethodInt(pNdbOperationD, interpretedUpdateTuple());
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
VerifyMethodInt(pNdbOperationD, incValue(c_szDistrictCount, Uint32(1)));
Uint32 nDistrictSum = myRandom48(100);
nWarehouseSum += nDistrictSum;
VerifyMethodInt(pNdbOperationD, setValue(c_szDistrictSum, nDistrictSum));
}
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
}
if(iExec==0) {
++nSucc;
} else {
++nFail;
}
VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
}
ndbout << "update: " << nSucc << " succeeded, " << nFail << " failed " << endl;
NdbMutex_Unlock(g_pNdbMutex);
delete pNdb;
pNdb = NULL ;
return NULL;
}
示例11: userDbInsertSubscriber
int userDbInsertSubscriber(UserHandle *uh,
SubscriberNumber number,
uint32 groupId,
SubscriberName name)
{
int check;
uint32 activeSessions = 0;
Location l = 0;
ChangedBy changedBy;
ChangedTime changedTime;
BaseString::snprintf(changedBy, sizeof(changedBy), "ChangedBy");
BaseString::snprintf(changedTime, sizeof(changedTime), "ChangedTime");
NdbConnection * MyTransaction = 0;
if(uh->pCurrTrans != 0){
MyTransaction = uh->pCurrTrans;
} else {
uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
}
if (MyTransaction == NULL)
error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
check = MyOperation->equal(SUBSCRIBER_NUMBER, number);
CHECK_MINUS_ONE(check, "equal", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId);
CHECK_MINUS_ONE(check, "setValue group", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l);
CHECK_MINUS_ONE(check, "setValue location", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions);
CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy);
CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime);
CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction);
return 0;
}
示例12: insert_subscriber
int
insert_subscriber(void * obj,
SubscriberNumber number,
SubscriberName name,
GroupId groupId,
Location l,
ActiveSessions activeSessions,
ChangedBy changedBy,
ChangedTime changedTime){
Ndb * pNDB = (Ndb *)obj;
int check;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
check = MyOperation->equal(SUBSCRIBER_NUMBER, number);
CHECK_MINUS_ONE(check, "equal", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId);
CHECK_MINUS_ONE(check, "setValue group", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l);
CHECK_MINUS_ONE(check, "setValue location", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions);
CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy);
CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime);
CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "commit", MyTransaction);
pNDB->closeTransaction(MyTransaction);
return 0;
}
示例13: QueryTransaction
int QueryTransaction(Ndb* pNdb,
long iContextId,
long* piVersion,
long* piLockFlag,
long* piLockTime,
long* piLockTimeUSec,
char* pchContextData,
NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
NdbRecAttr* pNdbRecAttrVersion;
NdbRecAttr* pNdbRecAttrLockFlag;
NdbRecAttr* pNdbRecAttrLockTime;
NdbRecAttr* pNdbRecAttrLockTimeUSec;
NdbRecAttr* pNdbRecAttrContextData;
if(!pNdbOperation->readTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
&& (pNdbRecAttrVersion=pNdbOperation->getValue(c_szVersion, (char*)piVersion))
&& (pNdbRecAttrLockFlag=pNdbOperation->getValue(c_szLockFlag, (char*)piLockFlag))
&& (pNdbRecAttrLockTime=pNdbOperation->getValue(c_szLockTime, (char*)piLockTime))
&& (pNdbRecAttrLockTimeUSec=pNdbOperation->getValue(c_szLockTimeUSec, (char*)piLockTimeUSec))
&& (pNdbRecAttrContextData=pNdbOperation->getValue(c_szContextData, pchContextData)))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例14: userDbInsertServer
int userDbInsertServer(UserHandle *uh,
ServerId serverId,
SubscriberSuffix suffix,
ServerName name)
{
int check;
uint32 noOfRead = 0;
uint32 noOfInsert = 0;
uint32 noOfDelete = 0;
NdbConnection * MyTransaction = 0;
if(uh->pCurrTrans != 0){
MyTransaction = uh->pCurrTrans;
} else {
uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
}
if (MyTransaction == NULL)
error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insert tuple", MyTransaction);
check = MyOperation->equal(SERVER_ID, (char*)&serverId);
CHECK_MINUS_ONE(check, "setValue id", MyTransaction);
check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix);
CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction);
check = MyOperation->setValue(SERVER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead);
CHECK_MINUS_ONE(check, "setValue reads", MyTransaction);
check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert);
CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction);
check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete);
CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction);
return 0;
}
示例15: insert_server
int
insert_server(void * obj,
ServerId serverId,
SubscriberSuffix suffix,
ServerName name,
Counter noOfRead,
Counter noOfInsert,
Counter noOfDelete){
Ndb * pNDB = (Ndb *)obj;
int check;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insert tuple", MyTransaction);
check = MyOperation->equal(SERVER_ID, (char*)&serverId);
CHECK_MINUS_ONE(check, "setValue id", MyTransaction);
check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix);
CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction);
check = MyOperation->setValue(SERVER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead);
CHECK_MINUS_ONE(check, "setValue reads", MyTransaction);
check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert);
CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction);
check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete);
CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "commit", MyTransaction);
pNDB->closeTransaction(MyTransaction);
return 0;
}