gtpc2mhrC/C++ Language Support User's Guide

TO2_isDDdefined-Test If DD Name Is Defined

This function tests the specified data store (DS) for the given data definition (DD) name.

Format

#include <c$to2.h>
long  TO2_isDDdefined (      TO2_ENV_PTR   env_ptr,
                       const char         *ddname,
                       const char         *dsname);

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

ddname
The pointer to a character string, which is the name of the data definition to be tested. The character string is assumed to be 32 characters in length. The name should be left-justified and padded with blanks (X'40') on the right if it less than 32 characters.

dsname
The pointer to a character string, which is the name of the data store that owns the data definition name (ddname). 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.

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

None.

Examples

The following example tests the specified data definition name to determine if it has already been created.

#include <c$to2.h>             /* Needed for TO2 API functions    */
#include <stdio.h>             /* APIs for standard I/O functions */
{
long         err_code=0;
TO2_ENV_PTR  env_ptr=0;        /* Pointer to TO2 environment      */
char         ddname[]="TEST1_DDNAME_FOR_TEST1_DS        ";
char         dsname[]="TEST1_DS";

  ·
  ·
  ·
if (TO2_isDDdefined(env_ptr, DDname, dsname) == TO2_ERROR) { err_code = TO2_getErrorCode(env_ptr); if (err_code == 0) printf("%s does not exist\n",ddname); else process_error(env_ptr); } else printf("%s already exists\n",ddname); }

Related Information