void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {

    int           check = -1 ;
    int           loop_count_ops = nRecords ;
    int           eOf = -1 ;
    int           readValue = 0 ;
    int           readValue2 = 0 ;
    int           scanCount = 0 ;
    TTYPE         fail = NO_FAIL ;

    for (int count=0 ; count < loop_count_ops ; count++)    {
        NdbConnection* MyTransaction = pMyNdb->startTransaction();
        if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        NdbOperation*  MyOperation = MyTransaction->getNdbOperation(tableName);
        if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        if (opType == 1)
            // Open for scan read, Creates the SCAN_TABREQ and if needed
            // SCAN_TABINFO signals.
            check = MyOperation->openScanRead(1);
        else if (opType == 2)
            // Open for scan with update of rows.
            check = MyOperation->openScanExclusive(1);

        // Create ATTRINFO signal(s) for interpreted program used for
        // defining search criteria and column values that should be returned.

        scanCount = count+1 ;

        switch(tupleType) {
        case 1:
            fail = t_exitMethods(scanCount, MyOperation,  opType);
            break;
        case 2:
            fail = t_incValue(scanCount, MyOperation);
            break;
        case 3:
            fail = t_subValue(scanCount, MyOperation);
            break;
        case 4:
            fail = t_readAttr(scanCount, MyOperation);
            break;
        case 5:
            fail = t_writeAttr(scanCount, MyOperation);
            break;
        case 6:
            fail = t_loadConst(scanCount, MyOperation,  opType);
            break;
        case 7:
            fail = t_branch(scanCount, MyOperation);
            break;
        case 8:
            fail = t_branchIfNull(scanCount, MyOperation);
            break;
        case 9:
            fail = t_addReg(scanCount, MyOperation);
            break;
        case 10:
            fail = t_subReg(scanCount, MyOperation);
            break;
        case 11:
            fail = t_subroutineWithBranchLabel(scanCount, MyOperation);
            break;
        default:
            break ;
        }

        if(11 != tupleType) MyOperation->getValue(attrName[1], (char*)&readValue);

        // Sends the SCAN_TABREQ, (SCAN_TABINFO) and ATTRINFO signals and then
        // reads the answer in TRANSID_AI. Confirmation is received through SCAN_TABCONF or
        // SCAN_TABREF if failure.
        check = MyTransaction->executeScan();
        if (check == -1) {
            //ndbout << endl << "executeScan returned: " << MyTransaction->getNdbError() << endl;
            error_handler(MyTransaction->getNdbError(), fail) ;
            pMyNdb->closeTransaction(MyTransaction);
        } else {
            // Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals.
            // SCAN_TABCONF or SCAN_TABREF is the confirmation.
            while ((eOf = MyTransaction->nextScanResult()) == 0) {
                ndbout << readValue <<"; ";
                // Here we call takeOverScanOp for update of the tuple.
            }
            ndbout << endl ;

            pMyNdb->closeTransaction(MyTransaction);
            if (eOf == -1) {
                ndbout << endl << "nextScanResult returned: "<< MyTransaction->getNdbError() << endl;
            } else {
                ndbout << "OK" << endl;
            }
        }
    }
    return;

};