gtpc2mflC/C++ Language Support User's Guide

TO2_nextPut-Store This Element As the Next Element

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.

Note:
This function does not support all collections. See Table 48 for collections that are supported for this function.

Format

#include <c$to2.h>
long TO2_nextPut (const TO2_PID_PTR  cursorPidPtr,
                        TO2_ENV_PTR  env_ptr,
                  const long        *dataLength,
                  const void        *data);

cursorPidPtr
The pointer to the cursor persistent identifier (PID) created by one of the TPF collection support (TPFCS) create cursor application programming interfaces (APIs).

env_ptr
The pointer to the environment as returned by the TO2_createEnv function.

dataLength
The length of the element that will be stored at the position after the element pointed to by the cursor.

data
The pointer to the actual data element that will be stored.

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