gtpc2me1C/C++ Language Support User's Guide

TO2_getCollectionKeys-Get the Primary Key Values of the Collection

This function returns a temporary sequence collection containing the primary key values for all elements in the collection.

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

Format

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

pid_ptr
The pointer to the persistent identifier (PID) assigned to the collection whose keys will be retrieved.

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

retnPid_ptr
The pointer to where the PID for the temporary sequence collection 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_ENV

TO2_ERROR_METHOD

TO2_ERROR_PID

Programming Considerations

Examples

The following example creates a temporary sequence collection containing the keys of all the elements in the source collection.

#include   <c$to2.h>          /* needed for TPFCS API functions     */
#include   <stdio.h>         /* APIs for standard I/O functions    */
 
TO2_PID	  keyedCol;       /* PID of source collection           */
TO2_ENV_PTR  env_ptr;        /* pointer to the TPFCS environment   */
TO2_PID      keys;           /* PID of sequence collection of keys */

  ·
  ·
  ·
if (TO2_getCollectionKeys(&keyedCol, env_ptr, &keys) == TO2_ERROR) { printf("TO2_getCollectionKeys failed!\n"); process_error(env_ptr); return; } else { printf("TO2_getCollectionKeys successful!\n"); }
  ·
  ·
  ·
TO2_deleteCollection(&keys, env_ptr);

Related Information