gtpc2mfl | C/C++ Language Support User's Guide |
This function stores the data as the next element in the collection. For sequence collections, the next element is inserted. For an array or binary large object (BLOB) collection, this function can be used to replace or add the next element.
Format
#include <c$to2.h> long TO2_nextPut (const TO2_PID_PTR cursorPidPtr, TO2_ENV_PTR env_ptr, const long *dataLength, const void *data);
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_CURSOR
TO2_ERROR_DATA_LGH
TO2_ERROR_ENV
TO2_ERROR_METHOD
TO2_ERROR_PID
TO2_ERROR_ZERO_PID
Programming Considerations
Examples
The following example stores a data element at the next element following where the cursor is currently pointing and then points the cursor to that element.
#include <c$to2.h> /* Needed for TO2 API Functions */ #include <stdio.h> /* APIs for standard I/O functions */ struct person_record { char *name; char *address; }; typedef struct person_record PERSON_RECORD; TO2_PID cursor; TO2_ENV_PTR env_ptr; /* Pointer to TO2 environment */ PERSON_RECORD *person_ptr; /* Pointer to the element data */ long dataLength;
·
·
·
/********************************************************************/ /* Store the data element where the cursor is currently pointing. */ /********************************************************************/ dataLength = sizeof(PERSON_RECORD); if (TO2_nextPut(&cursor, env_ptr, (u_char *) person_ptr, &dataLength) == TO2_ERROR) { printf("TO2_nextPut failed!\n"); process_error(env_ptr); } else printf("TO2_nextPut successful!\n");
Related Information