This section provides information about the
NdbRecAttr class.
- Parent class
None
- Child classes
None
- Description
-
NdbRecAttrcontains the value of an attribute. AnNdbRecAttrobject 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
NdbRecAttrobject 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 anNdbRecAttrobject has valid information only between the times thatNdbTransaction::execute()andNdb::closeTransaction()are called. The value of theNULLindicator is-1until theNdbTransaction::execute()method is invoked. - Methods
-
NdbRecAttrhas 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 Charattribute valueclone()Makes a deep copy of the RecAttrobjectdouble_value()Retrieves a Doubleattribute value, as a double (8 bytes)float_value()Retrieves a Floatattribute 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 NULLint8_value()Retrieves a Tinyintattribute value, as an 8-bit integerint32_value()Retrieves an Intattribute value, as a 32-bit integerint64_value()Retrieves a Bigintattribute value, as a 64-bit integermedium_value()Retrieves a Mediumintattribute value, as a 32-bit integershort_value()Retrieves a Smallintattribute value, as a 16-bit integeru_8_value()Retrieves a Tinyunsignedattribute value, as an unsigned 8-bit integeru_32_value()Retrieves an Unsignedattribute value, as an unsigned 32-bit integeru_64_value()Retrieves a Bigunsignedattribute value, as an unsigned 64-bit integeru_char_value()Retrieves a Charattribute value, as an unsignedcharu_medium_value()Retrieves a Mediumunsignedattribute value, as an unsigned 32-bit integeru_short_value()Retrieves a Smallunsignedattribute value, as an unsigned 16-bit integerThe
NdbRecAttrclass 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
NdbRecAttrclass defines no public types.
- Description
-
The
NdbRecAttrclass destructor method.You should delete only copies of
NdbRecAttrobjects 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
charpointer. 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
Charvalue stored in anNdbRecAttrobject, and returns it as achar.- Signature
char char_value ( void ) const- Parameters
None.
- Return value
A
charvalue.
- Description
-
This method creates a deep copy of an
NdbRecAttrobject.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
NdbRecAttrobject. This is a complete copy of the original, including all data.
- Description
This method gets a
Doublevalue stored in anNdbRecAttrobject, 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
Floatvalue stored in anNdbRecAttrobject, 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
Columnobject.
- 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::Typevalue.
- Description
This method gets a
Smallvalue stored in anNdbRecAttrobject, 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
Intvalue stored in anNdbRecAttrobject, 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
Bigintvalue stored in anNdbRecAttrobject, 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
Mediumintvalue stored in anNdbRecAttrobject, 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
Smallintvalue stored in anNdbRecAttrobject, 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
Smallunsignedvalue stored in anNdbRecAttrobject, 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
Unsignedvalue stored in anNdbRecAttrobject, 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
Bigunsignedvalue stored in anNdbRecAttrobject, 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
Charvalue stored in anNdbRecAttrobject, and returns it as an unsignedchar.- Signature
Uint8 u_char_value ( void ) const- Parameters
None.
- Return value
An 8-bit unsigned
charvalue.
- Description
This method gets an
Mediumunsignedvalue stored in anNdbRecAttrobject, 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
Smallunsignedvalue stored in anNdbRecAttrobject, 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.