/*******************************************************************************
**
** Source File Name = ilinfo.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 :
** Shows how to get/set info at installation image level.
**
** For more information about these samples see the README file.
**
** For more information on programming in CLI see the:
** - "Building CLI Applications" section of the Application Building Guide, and the
** - CLI Guide and Reference.
**
** For more information on the SQL language see the SQL Reference.
**
*******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlcli1.h>
#include "utilcli.h" /* Header file for CLI sample code */
/*******************************************************************
** main
*******************************************************************/
int main( int argc, char * argv[] )
{ SQLRETURN sqlrc = SQL_SUCCESS;
int rc = 0;
SQLHANDLE henv; /* environment handle */
SQLHANDLE hdbc; /* connection handle */
SQLHANDLE hstmt ; /* statement handle */
SQLUSMALLINT supported; /* to check if SQLGetInfo() is supported */
SQLCHAR imageInfoBuf[255]; /* buffer for image info */
SQLSMALLINT imageInfoInt ; /* integer to get image info */
SQLSMALLINT outlen;
char dbAlias[SQL_MAX_DSN_LENGTH + 1] ;
char user[MAX_UID_LENGTH + 1] ;
char pswd[MAX_PWD_LENGTH + 1] ;
/* checks the command line arguments */
rc = CmdLineArgsCheck1( argc, argv, dbAlias, user, pswd );
if ( rc != 0 ) return( rc ) ;
printf("\n\nNODES: GETTING/SETING INFO AT INSTALLATION IMAGE LEVEL.\n");
/* initialize the CLI application */
rc = CLIAppInit( dbAlias, user, pswd, &henv, &hdbc,
(SQLPOINTER)SQL_AUTOCOMMIT_ON);
if ( rc != 0 ) return( rc ) ;
printf("\nUSE THE CLI FUNCTIONS\n");
printf("-SQLGetFunctions\n-SQLGetInfo\n");
printf("TO GET:\n");
/*-->00000614.snippet */
/* check to see if SQLGetInfo() is supported */
sqlrc = SQLGetFunctions(hdbc, SQL_API_SQLGetInfo, &supported);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
/* 00000614.snippet <--*/
if (supported == SQL_TRUE)
{ sqlrc = SQLGetInfo(hdbc, SQL_DBMS_NAME, imageInfoBuf, 255, &outlen);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
printf(" Remote DBMS Name: %s\n", imageInfoBuf);
/*-->00000617.snippet */
sqlrc = SQLGetInfo(hdbc, SQL_DBMS_VER, imageInfoBuf, 255, &outlen);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
printf(" Remote DBMS Version: %s\n", imageInfoBuf);
/* 00000617.snippet <--*/
sqlrc = SQLGetInfo(hdbc, SQL_DRIVER_NAME, imageInfoBuf, 255, &outlen);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
printf(" Local CLI Driver Name: %s\n", imageInfoBuf);
sqlrc = SQLGetInfo(hdbc, SQL_DRIVER_VER, imageInfoBuf, 255, &outlen);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
printf(" Local CLI Driver Version: %s\n", imageInfoBuf);
sqlrc = SQLGetInfo(hdbc, SQL_ODBC_SQL_CONFORMANCE, &imageInfoInt,
sizeof(imageInfoInt), &outlen);
HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;
switch (imageInfoInt)
{ case SQL_OSC_MINIMUM:
strcpy((char *)imageInfoBuf, "Minimum Grammar");
break;
case SQL_OSC_CORE:
strcpy((char *)imageInfoBuf, "Core Grammar");
break;
case SQL_OSC_EXTENDED:
strcpy((char *)imageInfoBuf, "Extended Grammar");
break;
default:
break;
}
printf(" Local CLI Driver - ODBC SQL \n");
printf(" Conformance Level: %s\n", imageInfoBuf);
}
else printf( "\nSQLGetInfo is not supported!\n" ) ;
/* terminate the CLI application */
rc = CLIAppTerm( &henv, &hdbc, dbAlias);
return( rc ) ;
} /* end main */