gtpc2merC/C++ Language Support User's Guide

TO2_setDRprotect -- Set Dirty-Reader Protection On

This function activates dirty-reader protection for the collection. Dirty-reader protection determines whether TPF collection support (TPFCS) will use the FILNC macro or the FILEC macro to file records. If dirty-reader protection is on, TPFCS will use the FILNC macro to file records. TPF transaction services maintains a copy of each record filed using a FILNC macro. Maintaining a copy of each record filed can cause the size of TPF transaction services to be enlarged. It can also cause TPF transaction services to either exceed the maximum allowed size or to actually run out of TPF transaction services buffers. So, dirty-reader protection should only be set on a collection that will be accessed by dirty readers. When dirty-reader protection is turned on, it cannot be turned off.

Format

#include <c$to2.h>
long  TO2_setDRprotect(const TO2_PID_PTR  pid_ptr,
                             TO2_ENV_PTR  env_ptr);

pid_ptr
A pointer to the persistent identifier (PID) of the collection whose dirty-reader protection state is to be set on.

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

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:

Programming Considerations

To avoid running out of TPF transaction services buffers or exceeding the maximum allowed size, consider the following:

Examples

The following example activates dirty-reader protection for the provided collection.

#include <c$to2.h>                /* Needed for TO2 API functions     */
#include <stdio.h>                /* APIs for standard I/O functions  */
TO2_PID             pid_ptr;
TO2_ENV_PTR         env_ptr;

  ·
  ·
  ·
/**********************************************************************/ /* activate dirty-reader protection for the specified */ /* collection. */ /* '1' - successful, '-1' - error on request. */ /**********************************************************************/ if (TO2_setDRprotect(pid_ptr, env_ptr) == TO2_ERROR) { printf("TO2_setDRprotect failed!\n"); process_error(env_ptr); return -1; } else printf("TO2_setDRprotect successful!\n"); return 1;

Related Information

TO2_getDRprotect -- Retrieve Dirty-Reader Protection Status.