gtpc2mhkC/C++ Language Support User's Guide

TO2_getPIDforBrowseName-Retrieve the PID Associated with the Name

This function retrieves the persistent identifier (PID) of the given collection from the browser dictionary for the data store (DS) pointed to by the current environment pointer.

Format

#include <c$to2.h>
long TO2_getPIDforBrowseName (const TO2_PID_PTR  pid_ptr,
                                    TO2_ENV_PTR  env_ptr,
                              const char         name[]);

pid_ptr
The pointer to where the PID assigned to the given name will be returned.

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

name
The pointer to a string that is the name whose associated PID will be retrieved from the browser dictionary of the data store. The maximum name length is 32 bytes.

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_DATA_LGH

TO2_ERROR_METHOD

TO2_ERROR_NOT_INIT

TO2_ERROR_LOCATOR_NOT_FOUND

Programming Considerations

This function does not use TPF transaction services on behalf of the caller.

Examples

The following example retrieves the PID of the collection for the name COLLECTION1 from the browser dictionary for data store TEST1_DS.

#include <c$to2.h>               /* Needed for TO2 API functions    */
#include <stdio.h>               /* APIs for standard I/O functions */
 
TO2_ENV_PTR   env_ptr;           /* Pointer to the TO2 environment  */
TO2_PID       collectionPID;     /* named collection's returned PID */
long          userToken=0;       /* no user token value             */
char          applid[]="APPLICATION_NAME                 ";
char          dsname[]="TEST1_DS"; /*  data store name               */
char          name[]="COLLECTION1"; /* name to access                */

  ·
  ·
  ·
if (TO2_createEnv(&env_ptr, &userToken, applID, dsname) == TO2_ERROR) { printf("TO2_createEnv failed!\n"); process_error(env_ptr); } if (TO2_getPIDforBrowseName(&collectionPID, env_ptr, name) == TO2_ERROR) { printf("TO2_getPIDforBrowseName failed!\n"); process_error(env_ptr); } else { printf("TO2_getPIDforBrowseName was successful!\n"); }

Related Information