当前位置: 首页>>代码示例>>C++>>正文


C++ NdbConnection::updateTuple方法代码示例

本文整理汇总了C++中NdbConnection::updateTuple方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::updateTuple方法的具体用法?C++ NdbConnection::updateTuple怎么用?C++ NdbConnection::updateTuple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NdbConnection的用法示例。


在下文中一共展示了NdbConnection::updateTuple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
//.........这里部分代码省略.........
开发者ID:jimodb,项目名称:codes,代码行数:101,代码来源:ndb_async2.cpp

示例2: while

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);
    }

    const NdbOperation* op= NULL;

    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_NUMBER);
        SET_MASK(mask, IND_SUBSCRIBER_LOCATION);
        SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY);
        SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME);

        op= pCON->updateTuple(record,
                              rowPtr,
                              record,
                              rowPtr,
                              mask);
    }
    else
    {
        NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
        op= MyOp;
        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 (op != NULL)
    {
        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(NULL, "T1: getNdbOperation", td, pCON->getNdbError());
    }//if
}
开发者ID:jimodb,项目名称:codes,代码行数:63,代码来源:ndb_async2.cpp


注:本文中的NdbConnection::updateTuple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。