Neoview ODBC Drivers Manual (R2.5)

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 job id to 2468. */
SQLSetConnectAttr(hdbc, (void*)SQL_ATTR_SESSIONNAME,
(SQLCHAR*) "2468", 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);
Specifying an Application Name
SQL_ATTR_APPLNAME
Neoview ODBC provides the ability to specify an Application Name that persists for the duration
of a connection. By default, the application name is obtained from the application window title
or the name of the executable file, but you can override this value by specifying a connection
attribute.
To use this feature, include the Neoview-specific header file called hpsqlext.h in your
application, and specify the connection attribute SQL_ATTR_APPLNAME before the connection
is established. Once the connection is established, you may not change the attribute value.
Use the ODBC API SQLSetConnectAttr to set a connection attribute. Use the ODBC API
SQLGetConnectAttr to retrieve the current value.
The value of SQL_ATTR_APPLNAME has the following constraints:
It is a string value with a maximum length of 30 bytes.
The value is case sensitive, so “123abc” is different from “123ABC”.
International character sets are supported. (For information about Neoview support for
international character sets, see the HP Neoview Character Sets Administrator's Guide.
Examples
The following examples demonstrate the use of SQLSetConnectAttr to specify the application
name:
SQLRETURN rc;
SQLHDBC hdbc;
char *value = MSI;
. . .
26 HP Neoview ODBC Driver Overview for Windows