gtpc2mh9C/C++ Language Support User's Guide

TO2_getDSAttributes-Get the Attributes of the Data Store

This function returns a temporary sequence collection containing the names and values of the defined attributes for the specified data store (DS).

Format

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

pid_ptr
A pointer to a field where the persistent identifier (PID) of the temporary collection will be returned.

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

dsname
A pointer to the name of the DS with attributes that will be returned. The character string must be 8 characters or greater in length, left-justified, and padded with blanks (X'40') on the right.

Normal Return

The normal return is a positive value and the specified TO2_PID_PTR field will contain the PID of the temporary sequence collection.

The sequence collection will contain an element in the following format for each defined attribute:

    enum TO2_ATTRIBUTE_FORMAT
{
         TO2_ATTRIBUTE_CHAR = 'C',    /* format as character string   */
         TO2_ATTRIBUTE_DEC  = 'D',    /* format as decimal number     */
         TO2_ATTRIBUTE_HEX  = 'H' };  /* format as hexadecimal value  */
 
      struct TO2_attribute_element
{                         /*       */
         enum  TO2_ATTRIBUTE_FORMAT format_type; /* how to format     */
                                   /* attribute value.                */
         u_char    attr_val_lgh;   /* length of attribute field       */
         u_char    attr_nam_lgh;   /* length of attribute name        */
         char      attr_name[64];  /* attribute name
                                   /* attribute name = C'*****' is    */
                                   /* value continuation line for     */
                                   /* previously named attribute.     */
         u_char    attr_value[32]; /* attribute 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_DBID

TO2_ERROR_NOT_INIT

Programming Considerations

None.

Examples

The following example copies the attributes for the TPFDB data store.

#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 TO2 environment      */
TO2_PID          collectionPID;        /* return area for PID             */
 
char          DSname[9]      PFDB   "; /* data store name blank padded    */
TO2_ERR_CODE     to2_rc=1;             /* return code receiver            */
TO2_ERR_TEXT_PTR err_textPtr;          /* TO2 error code text pointer     */

  ·
  ·
  ·
{ if ((to2_rc = TO2_getDSAttributes(&collectionPID, env_ptr, DSname)) == TO2_ERROR) { to2_rc = TO2_getErrorCode(env_ptr); err_textPtr = TO2_getErrorText(env_ptr, to2_rc); printf ("TO2_getDSAttributes failed, error code - %d\n ", to2_rc); printf ("TO2 Error Text is %s\n ", err_textPtr); } else printf("TO2 get DS attributes successful\n"); }

Related Information