This section provides information about the
NdbRecAttr
class.
- Parent class
None
- Child classes
None
- Description
-
NdbRecAttr
contains the value of an attribute. AnNdbRecAttr
object is used to store an attribute value after it has been retrieved using theNdbOperation::getValue()
method. This object is allocated by the NDB API. A brief example is shown here:MyRecAttr = MyOperation->getValue("ATTR2", NULL); if(MyRecAttr == NULL) goto error; if(MyTransaction->execute(Commit) == -1) goto error; ndbout << MyRecAttr->u_32_value();
For additional examples, see Section 2.5.2, “NDB API Example Using Synchronous Transactions”.
An
NdbRecAttr
object is instantiated with its value only whenNdbTransaction::execute()
is invoked. Prior to this, the value is undefined. (UseNdbRecAttr::isNULL()
to check whether the value is defined.) This means that anNdbRecAttr
object has valid information only between the times thatNdbTransaction::execute()
andNdb::closeTransaction()
are called. The value of theNULL
indicator is-1
until theNdbTransaction::execute()
method is invoked. - Methods
-
NdbRecAttr
has a number of methods for retrieving values of various simple types directly from an instance of this class.It is also possible to obtain a reference to the value regardless of its actual type, by using
NdbRecAttr::aRef()
; however, you should be aware that this is not type-safe, and requires a cast from the user.The following table lists all of the public methods of this class and the purpose or use of each method:
Table 2.57 NdbRecAttr class methods and descriptions
Name Description ~NdbRecAttr()
Destructor method aRef()
Gets a pointer to the attribute value char_value()
Retrieves a Char
attribute valueclone()
Makes a deep copy of the RecAttr
objectdouble_value()
Retrieves a Double
attribute value, as a double (8 bytes)float_value()
Retrieves a Float
attribute value, as a float (4 bytes)get_size_in_bytes()
Gets the size of the attribute, in bytes getColumn()
Gets the column to which the attribute belongs getType()
Gets the attribute's type ( Column::Type
)isNULL()
Tests whether the attribute is NULL
int8_value()
Retrieves a Tinyint
attribute value, as an 8-bit integerint32_value()
Retrieves an Int
attribute value, as a 32-bit integerint64_value()
Retrieves a Bigint
attribute value, as a 64-bit integermedium_value()
Retrieves a Mediumint
attribute value, as a 32-bit integershort_value()
Retrieves a Smallint
attribute value, as a 16-bit integeru_8_value()
Retrieves a Tinyunsigned
attribute value, as an unsigned 8-bit integeru_32_value()
Retrieves an Unsigned
attribute value, as an unsigned 32-bit integeru_64_value()
Retrieves a Bigunsigned
attribute value, as an unsigned 64-bit integeru_char_value()
Retrieves a Char
attribute value, as an unsignedchar
u_medium_value()
Retrieves a Mediumunsigned
attribute value, as an unsigned 32-bit integeru_short_value()
Retrieves a Smallunsigned
attribute value, as an unsigned 16-bit integerThe
NdbRecAttr
class has no public constructor; an instance of this object is created usingNdbTransaction::execute()
. For information about the destructor, which is public, see ~NdbRecAttr(). - Types
The
NdbRecAttr
class defines no public types.
- Description
-
The
NdbRecAttr
class destructor method.You should delete only copies of
NdbRecAttr
objects that were created in your application using theclone()
method. - Signature
~NdbRecAttr ( void )
- Parameters
None.
- Return value
None.
- Description
This method is used to obtain a reference to an attribute value, as a
char
pointer. This pointer is aligned appropriately for the data type. The memory is released by the NDB API whenNdbTransaction::close()
is executed on the transaction which read the value.- Signature
char* aRef ( void ) const
- Parameters
A pointer to the attribute value. Because this pointer is constant, this method can be called anytime after
NdbOperation::getValue()
has been called.- Return value
None.
- Description
This method gets a
Char
value stored in anNdbRecAttr
object, and returns it as achar
.- Signature
char char_value ( void ) const
- Parameters
None.
- Return value