gtpc2mgtC/C++ Language Support User's Guide

TO2_defineBrowseNameForPID-Assign a Browse Name to a Collection

This function assigns the given name to the specified collection. Once assigned, the given name can be used on ZBROW functions to access the specified collection. The browse name to persistent identifier (PID) association is maintained in the browser dictionary for the data store (DS) pointed to by the current environment block.

Format

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

pid_ptr
The pointer to the PID assigned to the collection that is to be named.

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

name
The pointer to a string, which is the name to be assigned to the collection. 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_PID

TO2_ERROR_ZERO_PID

Programming Considerations

None.

Examples

The following example assigns the name COLLECTION1 to the input collection.

#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 PID         */
long          userToken=0;       /* no user token value             */
char          applid[]="APPLICATION_NAME                 ";
char          dsname[]="TEST1_DS"; /*  data store name              */
char          name[] = "COLLECTION1"; /* name to assign             */

  ·
  ·
  ·
/********************************************************************/ /* The collection must have been created before this function is */ /* invoked. */ /********************************************************************/ if (TO2_createEnv(&env_ptr, &userToken, applID, dsname) == TO2_ERROR) { printf("TO2_createEnv failed!\n"); process_error(env_ptr); } if (TO2_defineBrowseNameForPID(&collectionPID, env_ptr, name) == TO2_ERROR) { printf("TO2_defineBrowseNameForPID failed!\n"); process_error(env_ptr); } else { printf("TO2_defineBrowseNameForPID successful!\n"); }

Related Information