The world's most popular open source database
Description.
This method is used to fetch the next tuple in a scan
transaction. Following each call to
nextResult(), the buffers and
NdbRecAttr objects defined in
NdbOperation::getValue() are updated with
values from the scanned tuple.
Signature.
int nextResult
(
bool fetchAllowed = true,
bool forceSend = false
)
Beginning with MySQL Cluster NDB 6.2.3, it is also possible to use this method as shown here:
int nextResult
(
const char*& outRow,
bool fetchAllowed = true,
bool forceSend = false
)
Parameters. This method takes two parameters:
Normally, the NDB API contacts the
NDB kernel for more tuples whenever
it is necessary; setting
fetchAllowed to
false keeps this from happening.
Disabling fetchAllowed by
setting it to false forces
NDB to process any records it already
has in its caches. When there are no more cached records
it returns 2. You must then call
nextResult() with
fetchAllowed equal to
true in order to contact
NDB for more records.
While nextResult(false) returns
0, you should transfer the record to
another transaction. When
nextResult(false) returns
2, you must execute and commit the
other transaction. This causes any locks to be
transferred to the other transaction, updates or deletes
to be made, and then, the locks to be released.
Following this, call nextResult(true)
— this fetches more records and caches them in the
NDB API.
If you do not transfer the records to another
transaction, the locks on those records will be
released the next time that the NDB
Kernel is contacted for more records.
Disabling fetchAllowed can be
useful when you want to update or delete all of the
records obtained in a given transaction, as doing so
saves time and speeds up updates or deletes of scanned
records.
forceSend defaults to
false, and can normally be omitted.
However, setting this parameter to
true means that transactions are sent
immediately. See
Section 1.3.4, “The Adaptive Send Algorithm”, for more
information.
Parameters. Beginning with MySQL Cluster NDB 6.2.3, this method can also be called with the following parameters:
Calling nextResult() sets a pointer
to the next row in outRow (if
returning 0). This pointer is valid (only) until the
next call to nextResult() when
fetchAllowed is true. The
NdbRecord object defining the row
format must be specified beforehand using
NdbTransaction::scanTable() (or
NdbTransaction::scanIndex().
When false, fetchAllowed
forces NDB to process any records it
already has in its caches. See the description for this
parameter in the previous
Parameters subsection for more
details.
Setting forceSend to
true means that transactions are sent
immediately, as described in the previous
Parameters subsection, as well as
in Section 1.3.4, “The Adaptive Send Algorithm”.
Return Value. This method returns one of the following 4 integer values:
-1: Indicates that an error has
occurred.
0: Another tuple has been received.
1: There are no more tuples to scan.
2: There are no more cached records
(invoke nextResult(true) to fetch
more records).

