To set the attribute values of a structured UDT that is defined to be the result of a UDF, follow these steps.
IF the attribute … | THEN … |
---|---|
does not represent a LOB | Allocate a buffer using the C data type that maps to the underlying type of the attribute. Place the value of the attribute into the buffer. Call FNC_SetStructuredAttribute or FNC_SetStructuredAttributeByNdx to set the value of the attribute to the value in the buffer you allocated. You can also set the attribute to null. |
represents a LOB | Declare a LOB_RESULT_LOCATOR to hold the locator of the LOB attribute. Call FNC_GetStructuredResultLobAttribute or FNC_GetStructuredResultLobAttributeByNdx to set the LOB_RESULT_LOCATOR to the locator of the LOB attribute. Follow the steps in Appending Data to a Large Object Result to append the return data using the LOB locator. |
For details on FNC_SetStructuredAttribute, FNC_SetStructuredAttributeByNdx, FNC_GetStructuredResultLobAttribute, and FNC_GetStructuredResultLobAttributeByNdx, see C Library Functions.
The following code excerpt sets the attribute value of a structured UDT:
void setX( UDT_HANDLE *pointUdt, INTEGER *val, UDT_HANDLE *resultPoint, char sqlstate[6]) { INTEGER x; INTEGER newval; int nullIndicator; int length; /* Set the x attribute of the result point. */ nullIndicator = 0; newval = *val; FNC_SetStructuredAttribute(*resultPoint, "x", &newval, nullIndicator, SIZEOF_INTEGER); ... }