gtpc2mfw | C/C++ Language Support User's Guide |
This function points the cursor at the specified element. This function is not supported for arrays, binary large objects (BLOBs), logs, and sequence collections. For key sorted set, sorted bag, sorted key bag, and sorted set collections, a pointer to a key or sort field value is required. For bags and sets, a pointer to a value that will be used to access the collection is required. If there is more than one entry with the same value, the cursor will be positioned to the first entry found.
Format
#include <c$to2.h> long TO2_setPositionValue (const TO2_PID_PTR cursorPidPtr, TO2_ENV_PTR env_ptr, const long *valueL, const void *value);
Normal Return
The normal return is a positive value.
Error Return
An error return is indicated by a zero. When zero is returned, use the TO2_getErrorCode function to determine the specific error code. For more information, see Error Handling.
The following error codes are common for this function:
TO2_ERROR_ENV
TO2_ERROR_LOCATOR_LGH
TO2_ERROR_METHOD
TO2_ERROR_PID
TO2_ERROR_ZERO_PID
Programming Considerations
Examples
The following example points the cursor at the element matching the specified criteria.
#include <c$to2.h> /* Needed for TO2 API Functions */ #include <stdio.h> /* APIs for standard I/O functions */ struct person_record { char name[20]; char address[60]; }; typedef struct person_record PERSON_RECORD; TO2_PID cursor; TO2_ENV_PTR env_ptr; PERSON_RECORD data; long dataLength;
·
·
·
/*********************************************************************/ /* Point the cursor to the element matching the key specified. */ /*********************************************************************/ dataLength = sizeof(PERSON_OBJ); if (TO2_setPositionValue(&cursor, env_ptr, &dataLength, &data) == TO2_ERROR) { printf("TO2_setPositionValue failed!\n"); process_error(env_ptr); } else printf("TO2_setPositionValue successful!\n");
Related Information