本文整理汇总了C++中Statement::GetColumnAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::GetColumnAttribute方法的具体用法?C++ Statement::GetColumnAttribute怎么用?C++ Statement::GetColumnAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::GetColumnAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQLDescribeCol
SQLRETURN SQLDescribeCol(SQLHSTMT stmt,
SQLUSMALLINT columnNum,
SQLCHAR* columnNameBuf,
SQLSMALLINT columnNameBufLen,
SQLSMALLINT* columnNameLen,
SQLSMALLINT* dataType,
SQLULEN* columnSize,
SQLSMALLINT* decimalDigits,
SQLSMALLINT* nullable)
{
using odbc::Statement;
using odbc::SqlLen;
LOG_MSG("SQLDescribeCol called");
Statement *statement = reinterpret_cast<Statement*>(stmt);
if (!statement)
return SQL_INVALID_HANDLE;
statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
SqlLen dataTypeRes;
SqlLen columnSizeRes;
SqlLen decimalDigitsRes;
SqlLen nullableRes;
statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
LOG_MSG("columnNum: " << columnNum);
LOG_MSG("dataTypeRes: " << dataTypeRes);
LOG_MSG("columnSizeRes: " << columnSizeRes);
LOG_MSG("decimalDigitsRes: " << decimalDigitsRes);
LOG_MSG("nullableRes: " << nullableRes);
LOG_MSG("columnNameBuf: " << (columnNameBuf ? reinterpret_cast<const char*>(columnNameBuf) : "<null>"));
LOG_MSG("columnNameLen: " << (columnNameLen ? *columnNameLen : -1));
if (dataType)
*dataType = static_cast<SQLSMALLINT>(dataTypeRes);
if (columnSize)
*columnSize = static_cast<SQLULEN>(columnSizeRes);
if (decimalDigits)
*decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
if (nullable)
*nullable = static_cast<SQLSMALLINT>(nullableRes);
return statement->GetDiagnosticRecords().GetReturnCode();
}
示例2: SQLColAttribute
SQLRETURN SQLColAttribute(SQLHSTMT stmt,
SQLUSMALLINT columnNum,
SQLUSMALLINT fieldId,
SQLPOINTER strAttr,
SQLSMALLINT bufferLen,
SQLSMALLINT* strAttrLen,
SQLLEN* numericAttr)
{
using odbc::Statement;
using odbc::meta::ColumnMetaVector;
using odbc::meta::ColumnMeta;
LOG_MSG("SQLColAttribute called: " << fieldId << " (" << ColumnMeta::AttrIdToString(fieldId) << ")");
Statement *statement = reinterpret_cast<Statement*>(stmt);
if (!statement)
return SQL_INVALID_HANDLE;
// This is a special case
if (fieldId == SQL_DESC_COUNT)
{
SQLSMALLINT val = 0;
SQLRETURN res = SQLNumResultCols(stmt, &val);
if (numericAttr && res == SQL_SUCCESS)
*numericAttr = val;
return res;
}
statement->GetColumnAttribute(columnNum, fieldId, reinterpret_cast<char*>(strAttr),
bufferLen, strAttrLen, numericAttr);
return statement->GetDiagnosticRecords().GetReturnCode();
}