setAttrValue()

Sets the value of an attribute.

Syntax

unsigned char setAttrValue(char * name, void * newval, int type);
unsigned char setAttrValue(int position, void * newVal, int type);

Parameters

name [in]
Is the name of the attribute whose value you want to set.

position[in]
Is an integer that specifies the ordinal position of the attribute in the business object's attribute list.

newVal [in]
Is either a string representation of the value for the attribute or a pointer to the value. Must be char * or BusinessObject *.

type [in]
Is one of the following attribute data types for the new value, as represented by one of the following constants:
BOAttrType::OBJECT

 
BOAttrType::BOOLEAN

 
BOAttrType::INTEGER

 
BOAttrType::FLOAT

 
BOAttrType::DOUBLE

 
BOAttrType::STRING

 
BOAttrType::DATE

 
BOAttrType::LONGTEXT

Return values

Returns True when the operation succeeded or False when the operation failed.

Notes

You can use the name or position method to set an attribute value. These methods verify that the new value has the correct data type before changing the attribute value. If newval is a character pointer, the method sets the value. If type is OBJECT and the attribute refers to a single cardinality object, the setAttrValue() method overwrites the previous business object with the new business object. If type is OBJECT and the attribute refers to a multiple cardinality object, the setAttrValue() method appends the business object to the container.

You can set an attribute to a special value, either BusinessObject::BlankValue or BusinessObject::IgnoreValue. Blank means "clear this field; there is no data in it." Ignore means "I don't know or don't care what is in this field."

Examples

unsigned char status;
if (status = pObj->setAttrValue("Interest Rate","0.065",
      BOAttrType::FLOAT);) == 0)
   // continue

See also

getAttrValue() setDefaultAttrValues()

Copyright IBM Corp. 1997, 2004