gtpc2mg6C/C++ Language Support User's Guide

TO2_atTPFKeyPut-Replace the Element Using the Specified Key

This function locates the entry represented by the specified key and replaces its contents with the passed data values. The passed key is assumed to be 64 bytes in length.

Format

#include <c$to2.h>
long  TO2_atTPFKeyPut (      TO2_ENV_PTR  env_ptr,
                       const void        *key,
                       const long        *dataLength,
                       const void        *data,
                       const long        *updateSeqCtr);

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

key
The pointer to the EBCDIC key to use to locate the dictionary entry. The passed key is assumed to be 64 bytes in length.

dataLength
The pointer to the length of the data to place in the entry.

data
The pointer to the data to place in the entry.

updateSeqCtr
The pointer to an area where the update sequence counter from a TO2_at request has been stored. If this sequence counter value is not equal to the current update sequence counter value of the collection, the TO2_atPut request will not be run.

Normal Return

The normal return is a positive value. The entry represented by the specified key is updated in the dictionary.

Error Return

An error return is indicated by a zero. When zero is returned, the TO2_getErrorCode function can be used 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_NOT_FOUND

TO2_ERROR_SEQCTR

Programming Considerations

A commit scope will be created for the TO2_atTPFKeyPut request. If the request is successful, the scope will be committed. If an error occurs while processing the TO2_atTPFKeyPut request, the scope will be rolled back.

Examples

The following example updates an element in the TPF system dictionary.

#include <c$to2.h>                /* Needed for TO2 API Functions     */
#include <stdio.h>                /* APIs for standard I/O functions  */
 
TO2_ERR_CODE     err_code;        /* TO2 error code value             */
TO2_ERR_TEXT_PTR err_text_ptr;    /* TO2 error code text pointer      */
 
u_char key[64]
= "TPF.Key.is.64.characters.long                                   ";
 
u_char data[]
= "This.is.some.data.for.the.TPF.Dictionary";
 
long dataLength;
long UpdateSeqCtr = 0;

  ·
  ·
  ·
datalength = sizeof(data); if (TO2_atTPFKeyPut(env_ptr, key, &dataLength, data, &updateSeqCtr) == TO2_ERROR) { printf("atTPFKeyPut failed!\n"); err_code = TO2_getErrorCode(env_ptr); err_text_ptr = TO2_getErrorText(env_ptr, err_code); printf("err_text_ptr is %s\n", err_text_ptr); } else printf("atTPFKeyPut is successful!\n");
  ·
  ·
  ·

Related Information