本文整理汇总了C++中NdbConnection::readTuple方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::readTuple方法的具体用法?C++ NdbConnection::readTuple怎么用?C++ NdbConnection::readTuple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbConnection
的用法示例。
在下文中一共展示了NdbConnection::readTuple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/**
* Transaction 2 - T2
*
* Read from Subscriber:
*
* Input:
* SubscriberNumber
*
* Output:
* Location
* Changed by
* Changed Timestamp
* Name
*/
void
start_T2(Ndb * pNDB, ThreadData * td, int async) {
DEBUG3("T2(%.*s, %d): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.location);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0) {
CHECK_ALLOWED_ERROR("T2-1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
if (td->ndbRecordSharedData)
{
char* rowPtr= (char*) &td->transactionData;
const NdbRecord* record= td->ndbRecordSharedData->
subscriberTableNdbRecord;
Uint32 m=0;
unsigned char* mask= (unsigned char*) &m;
SET_MASK(mask, IND_SUBSCRIBER_LOCATION);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME);
SET_MASK(mask, IND_SUBSCRIBER_NAME);
const NdbOperation* MyOp= pCON->readTuple(record, rowPtr, record, rowPtr,
NdbOperation::LM_Read, mask);
CHECK_NULL((void*) MyOp, "T2: readTuple", td,
pCON->getNdbError());
}
else
{
NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOp, "T2: getNdbOperation", td,
pCON->getNdbError());
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);
}
if (async == 1) {
pCON->executeAsynchPrepare( Commit , T2_Callback, td);
} else {
int result = pCON->execute(Commit);
T2_Callback(result, pCON, (void*)td);
return;
}//if
}
示例2: program
/**
* Transaction 5 - T5
*
* Delete session
*
* Input:
* SubscriberNumber
* ServerId
* ServerBit
* DoRollback
* Output:
* ChangedBy
* ChangedTime
* Location
* BranchExecuted
*/
void
start_T5(Ndb * pNDB, ThreadData * td, int async) {
DEBUG3("T5(%.*s, %.2d): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0) {
CHECK_ALLOWED_ERROR("T5-1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
if (td->ndbRecordSharedData)
{
char* rowPtr= (char*) &td->transactionData;
const NdbRecord* record= td->ndbRecordSharedData->
subscriberTableNdbRecord;
Uint32 m=0;
unsigned char* mask= (unsigned char*) &m;
SET_MASK(mask, IND_SUBSCRIBER_LOCATION);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME);
SET_MASK(mask, IND_SUBSCRIBER_GROUP);
SET_MASK(mask, IND_SUBSCRIBER_SESSIONS);
const NdbOperation* MyOp= pCON->readTuple(record, rowPtr, record, rowPtr,
NdbOperation::LM_Read,
mask);
CHECK_NULL((void*)MyOp, "T5-1: readTuple", td,
pCON->getNdbError());
m= 0;
/* Create program to subtract something from the
* subscriber sessions column
*/
Uint32 codeBuf[20];
NdbInterpretedCode program(pNDB->getDictionary()->
getTable(SUBSCRIBER_TABLE),
codeBuf,
20);
if (program.sub_val(IND_SUBSCRIBER_SESSIONS,
(uint32)td->transactionData.server_bit) ||
program.interpret_exit_ok() ||
program.finalise())
{
CHECK_NULL(NULL , "T5: Program create failed", td,
program.getNdbError());
}
NdbOperation::OperationOptions opts;
opts.optionsPresent= NdbOperation::OperationOptions::OO_INTERPRETED;
opts.interpretedCode= &program;
MyOp= pCON->updateTuple(record, rowPtr, record, rowPtr,
mask,
&opts,
sizeof(opts));
CHECK_NULL((void*)MyOp, "T5-1: updateTuple", td,
pCON->getNdbError());
}
else
{
/* Use old Api */
if (td->useCombinedUpdate)
{
NdbOperation * MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOp, "T5-1: getNdbOperation", td,
pCON->getNdbError());
MyOp->interpretedUpdateTuple();
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_GROUP,
(char *)&td->transactionData.group_id);
MyOp->getValue(IND_SUBSCRIBER_SESSIONS,
(char *)&td->transactionData.sessions);
//.........这里部分代码省略.........