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
A
char
value.
- Description
-
This method creates a deep copy of an
NdbRecAttr
object.The copy created by this method should be deleted by the application when no longer needed.
- Signature
NdbRecAttr* clone ( void ) const
- Parameters
None.
- Return value
An
NdbRecAttr
object. This is a complete copy of the original, including all data.
- Description
This method gets a
Double
value stored in anNdbRecAttr
object, and returns it as a double.- Signature
double double_value ( void ) const
- Parameters
None.
- Return value
A double (8 bytes).
- Description
This method gets a
Float
value stored in anNdbRecAttr
object, and returns it as a float.- Signature
float float_value ( void ) const
- Parameters
None.
- Return value
A float (4 bytes).
- Description
You can use this method to obtain the size of an attribute (element).
- Signature
Uint32 get_size_in_bytes ( void ) const
- Parameters
None.
- Return value
The attribute size in bytes, as an unsigned 32-bit integer.
- Description
This method is used to obtain the column to which the attribute belongs.
- Signature
const NdbDictionary::Column* getColumn ( void ) const
- Parameters
None.
- Return value
A pointer to a
Column
object.
- Description
This method is used to obtain the column's data type.
- Signature
NdbDictionary::Column::Type getType ( void ) const
- Parameters
None.
- Return value
A
Column::Type
value.
- Description
This method gets a
Small
value stored in anNdbRecAttr
object, and returns it as an 8-bit signed integer.- Signature
Int8 int8_value ( void ) const
- Parameters
None.
- Return value
An 8-bit signed integer.
- Description
This method gets an
Int
value stored in anNdbRecAttr
object, and returns it as a 32-bit signed integer.- Signature
Int32 int32_value ( void ) const
- Parameters
None.
- Return value
A 32-bit signed integer.
- Description
This method gets a
Bigint
value stored in anNdbRecAttr
object, and returns it as a 64-bit signed integer.- Signature
Int64 int64_value ( void ) const
- Parameters
None.
- Return value
A 64-bit signed integer.
- Description
This method checks whether a given attribute value is
NULL
.- Signature
int isNULL ( void ) const
- Parameters
None.
- Return value
-
One of the following three values:
-1
: The attribute value is not defined due to an error.0
: The attribute value is defined, but is notNULL
.1
: The attribute value is defined and isNULL
.
In the event that
NdbTransaction::execute()
has not
yet been called, the value returned by isNULL()
is not determined.
- Description
Gets the value of a
Mediumint
value stored in anNdbRecAttr
object, and returns it as a 32-bit signed integer.- Signature
Int32 medium_value ( void ) const
- Parameters
None.
- Return value
A 32-bit signed integer.
- Description
This method gets a
Smallint
value stored in anNdbRecAttr
object, and returns it as a 16-bit signed integer (short).- Signature
short short_value ( void ) const
- Parameters
None.
- Return value
A 16-bit signed integer.
- Description
This method gets a
Smallunsigned
value stored in anNdbRecAttr
object, and returns it as an 8-bit unsigned integer.- Signature
Uint8 u_8_value ( void ) const
- Parameters
None.
- Return value
An 8-bit unsigned integer.
- Description
This method gets an
Unsigned
value stored in anNdbRecAttr
object, and returns it as a 32-bit unsigned integer.- Signature
Uint32 u_32_value ( void ) const
- Parameters
None.
- Return value
A 32-bit unsigned integer.
- Description
This method gets a
Bigunsigned
value stored in anNdbRecAttr
object, and returns it as a 64-bit unsigned integer.- Signature
Uint64 u_64_value ( void ) const
- Parameters
None.
- Return value
A 64-bit unsigned integer.
- Description
This method gets a
Char
value stored in anNdbRecAttr
object, and returns it as an unsignedchar
.- Signature
Uint8 u_char_value ( void ) const
- Parameters
None.
- Return value
An 8-bit unsigned
char
value.
- Description
This method gets an
Mediumunsigned
value stored in anNdbRecAttr
object, and returns it as a 32-bit unsigned integer.- Signature
Uint32 u_medium_value ( void ) const
- Parameters
None.
- Return value
A 32-bit unsigned integer.
- Description
This method gets a
Smallunsigned
value stored in anNdbRecAttr
object, and returns it as a 16-bit (short) unsigned integer.- Signature
Uint16 u_short_value ( void ) const
- Parameters
None.
- Return value
A short (16-bit) unsigned integer.