[This is preliminary documentation and subject to change.]
The following pseudocode assumes a typical client-adapter interaction. The client wants to select c1t1 from table t1 in the database called Wellfleet. In CIM terms, this corresponds to getting the property fld1t1 from all instances of the class t1. This pseudocode for the client does not consider error handling.
HENV henv;
HBDC hdbc;
HSTMT hstmt;
SQLAllocEnv (&henv);
SQLAllocConnect (henv, &hdbc);
SQLConnect (hdbc, "SNMP", SQL_NTS,
NULL, SQL_NTS, NULL, SQL_NTS);
SQLSetConnectionOption (hdbc, SQL_CURRENT_QUALIFIER,
"Wellfleet");
HSTMT hstmt;
SQLAllocStmt (hdbc, &hstmt);
SQLExecDirect (hstmt, "select c1t1 from t1");
while (SQL_SUCCESS == SQLFetch (hstmt))
{
char szData [MAX_DATA];
SQLGetData (hstmt, 1, SQL_C_CHAR,
szData, sizeof (szData), &cbData));
MsgBox (NULL, szData, "ODBC", MB_OK);
}
Using SQLSetConnectionOption with the SQL_CURRENT_QUALIFER option sets the default database. This means the client can refer to tables without having to qualify them with the database name (in this case, Wellfleet). If the client had not invoked the SQLSetConnectOption, the adapter would have searched for t1 in the current database. In SQLSetConnectOption, the adapter stores the database (qualifier) in a data structure associated with the hdbc (the connection handle).