The world's most popular open source database
Description. This method is used to execute a transaction.
Signature.
int execute
(
ExecType execType,
NdbOperation::AbortOption abortOption = NdbOperation::DefaultAbortOption,
int force = 0
)
Parameters. The execute method takes 3 parameters, as described here:
The execution type (ExecType value);
see Section 4.19.1.3, “The NdbTransaction::ExecType Type”, for
more information and possible values.
An abort option
(NdbOperation::AbortOption value).
Prior to MySQL Cluster NDB 6.2.0,
abortOption was of type
NdbTransaction::AbortOption (which
became a member of NdbOperation in
MySQL Cluster NDB 6.2.0), and its default value was
NdbTransaction::AbortOnError. See
Section 4.15.1.1, “The NdbOperation::AbortOption Type”, for
more information.
A force parameter, which
determines when operations should be sent to the
NDB Kernel:
0: Non-forced; detected by the
adaptive send algorithm.
1: Forced; detected by the
adaptive send algorithm.
2: Non-forced; not detected by
the adaptive send algorithm.
Return Value.
0 on success, -1 on
failure. The fact that the transaction did not abort does not
necessarily mean that each operation was successful; you must
check each operation individually for errors.
In MySQL 5.1.15 and earlier versions, this method returned
-1 for some errors even when the trasnsaction
itself was not aborted; beginning with MySQL 5.1.16, this method
reports a failure if and only if the
transaction was aborted. (This change was made due to the fact
it had been possible to construct cases where there was no way
to determine whether or not a transaction was actually aborted.)
However, the transaction's error information is still set in
such cases to reflect the actual error code and category.
This means, in the case where a NoDataFound error is a possibility, you must now check for it explicitly, for example:
Ndb_cluster_connection myConnection;
if( myConnection.connect(4, 5, 1) )
{
cout << "Unable to connect to cluster within 30 secs." << endl;
exit(-1);
}
Ndb myNdb(&myConnection, "test");
// define operations...
myTransaction = myNdb->startTransaction();
if(myTransaction->getNdbError().classification == NdbError:NoDataFound)
{
cout << "No records found." << endl;
// ...
}
myNdb->closeTransaction(myTransaction);

