Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual

2.3.25.17 NdbOperation::setValue()

Description.  This method defines an attribute to be set or updated.

There are a number of NdbOperation::setValue() methods that take a certain type as input (pass by value rather than passing a pointer). It is the responsibility of the application programmer to use the correct types.

However, the NDB API does check that the application sends a correct length to the interface as given in the length parameter. A char* value can contain any data type or any type of array. If the length is not provided, or if it is set to zero, then the API assumes that the pointer is correct, and does not check it.

To set a NULL value, use the following construct:

setValue("ATTR_NAME", (char*)NULL);

When you use insertTuple(), the NDB API automatically detects that it is supposed to use equal() instead.

In addition, it is not necessary when using insertTuple() to use setValue() on key attributes before other attributes.

Signature.  There are 14 versions of NdbOperation::setValue(), each with slightly different parameters, as listed here (and summarized in the Parameters section following):

int setValue
    (
      const char* name,
      const char* value
)

int setValue
    (
      const char* name,
      Int32       value
    )

int setValue
    (
      const char* name,
      Uint32      value
    )

int setValue
    (
      const char* name,
      Int64       value
    )

int setValue
    (
      const char* name,
      Uint64      value
    )

int setValue
    (
      const char* name,
      float       value
    )

int setValue
    (
      const char* name,
      double      value
    )

int setValue
    (
      Uint32      id,
      const char* value
    )

int setValue
    (
      Uint32 id,
      Int32  value
    )

int setValue
    (
      Uint32 id,
      Uint32 value
    )

int setValue
    (
      Uint32 id,
      Int64  value
    )

int setValue
    (
      Uint32 id,
      Uint64 value
    )

int setValue
    (
      Uint32 id,
      float  value
    )

int setValue
    (
      Uint32 id,
      double value
    )

Parameters.  This method requires the following two parameters:

  • The first parameter identified the attribute to be set, and may be either one of the following:

    1. The attribute name (a string)

    2. The attribute id (an unsigned 32-bit integer)

  • The second parameter is the value to which the attribute is to be set; its type may be any one of the following 7 types:

    1. String (const char*)

    2. 32-bit integer

    3. Unsigned 32-bit integer

    4. 64-bit integer

    5. Unsigned 64-bit integer

    6. Double

    7. Float

See Section 2.3.25.3, “NdbOperation::equal()”, for important information regarding the value's format and length.

Return value.  Returns -1 in the event of failure.


User Comments
Sign Up Login You must be logged in to post a comment.