Neoview ODBC Drivers Manual (R2.4)

Example
The following examples demonstrate the use of SQLSetConnectAttr to specify the application
name:
SQLRETURN rc;
SQLHDBC hdbc;
char *value = MSI;
. . .
rc = SQLSetConnectAttr(hdbc, SQL_ATTR_APPLNAME, value, strlen(value));
. . .
#include hpsqlext.h
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
/*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
/* Set the ODBC version environment attribute */
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
/* Allocate connection handle */
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
/* Set application name to "HPDM" */
SQLSetConnectAttr(hdbc, (void*)SQL_ATTR_APPLNAME, (SQLCHAR*) "HPDM", SQL_NTS);
/* Connect to data source */
retcode = SQLConnect(hdbc, (SQLCHAR*) "RUSH", SQL_NTS,
(SQLCHAR*) "Neo", SQL_NTS,
(SQLCHAR*) "Neo", SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
/* Process data */
...;
...;
...;
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
INFOSTATS Command
INFOSTATS is a pass-through command that collects statistics for a prepared statement. Statistics
are returned to the ODBC application as a result set as soon as the PREPARE is finished. The
result set has these columns:
Query ID (SQL_CHAR)
CPUTime (SQL_DOUBLE): An estimate of the number of seconds of processor time it might
take to execute the instructions for this query. A value of 1.0 is 1 second.
IOTime (SQL_DOUBLE): An estimate of the number of seconds of I/O time (seeks plus data
transfer) to perform the I/O for this query.
MsgTime (SQL_DOUBLE): An estimate of the number of seconds it takes for the messaging
for this query. The estimate includes the time for the number of local and remote messages
and the amount of data sent.
32 HP Neoview ODBC Drivers Overview for UNIX