/*******************************************************************************
**
** Source File Name = dbcmt.c
**
** Licensed Materials - Property of IBM
**
** (C) COPYRIGHT International Business Machines Corp. 1995, 2000
** All Rights Reserved.
**
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
**
**
** PURPOSE :
** This program is an example of how APIs are implemented in order to
** change the comment for a database.
**
** STRUCTURES USED :
** sqledinfo
** sqlca
**
** APIs USED :
** CHANGE DATABASE COMMENT sqledcgd
** INSTALL SIGNAL HANDLER sqleisig
** OPEN DATABASE DIRECTORY SCAN sqledosd
** GET NEXT DATABASE ENTRY sqledgne
** CLOSE DATABASE DIRECTORY SCAN sqledcls
**
**
** FUNCTIONS DECLARED :
** 'C' COMPILER LIBRARY :
** stdio.h - printf
** string.h - strncmp
**
** DBMS LIBRARY :
** sqlenv.h - see "APIs USED" above
**
** OTHER :
** external :
** check_error : Checks for SQLCODE error, and prints out any
** [in UTIL.C] related information available.
**
**
** EXTERNAL DEPENDENCIES :
** - Ensure existence of database for precompile purposes.
** - Compile and link with the IBM Cset++ compiler (AIX and OS/2)
** or the Microsoft Visual C++ compiler (Windows)
** or the compiler supported on your platform.
**
** For more information about these samples see the README file.
**
** For more information on programming in C, see the:
** - "Programming in C and C++" section of the Application Development Guide
** For more information on Building C Applications, see the:
** - "Building C Applications" section of the Application Building Guide.
**
** For more information on the SQL language see the SQL Reference.
**
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include "utilapi.h"
int main (void) {
struct sqlca sqlca;
unsigned short idx;
unsigned short dbHandle;
unsigned short dbCount;
struct sqledinfo *dbBuffer;
/*************************************\
* INSTALL SIGNAL HANDLER API called *
\*************************************/
sqleisig( &sqlca);
/*****************************************\
* OPEN DATABASE DIRECTORY SCAN API called *
\*****************************************/
sqledosd ("\0", &dbHandle, &dbCount, &sqlca);
API_SQL_CHECK("opening the database directory scan API");
printf ("opened directory scan\n");
for (idx = 0; idx < dbCount; idx++) {
/************************************\
* GET NEXT DATABASE ENTRY API called *
\************************************/
sqledgne (dbHandle, &dbBuffer, &sqlca);
API_SQL_CHECK("getting next database entry API");
strncmp("SAMPLE ",dbBuffer->alias,SQL_ALIAS_SZ);
if (strncmp("SAMPLE ",dbBuffer->alias,SQL_ALIAS_SZ) == 0) {
printf ("alias found\n");
/*****************************\
* CHANGE DATABASE COMMENT API *
\*****************************/
sqledcgd ("SAMPLE", "", "the new comment for sample",
&sqlca);
API_SQL_CHECK("changing comment");
printf ("CHANGE DATABASE COMMENT successful\n");
/*********************************\
* RESET DATABASE COMMENT TO BLANK *
\*********************************/
sqledcgd ("SAMPLE", "", "",
&sqlca);
API_SQL_CHECK("reset comment");
break;
} /* endif */
} /* endfor */
/******************************************\
* CLOSE DATABASE DIRECTORY SCAN API called *
\******************************************/
sqledcls (dbHandle, &sqlca);
API_SQL_CHECK("closing the node directory scan");
return 0;
}