Library: ODBC
Package: ODBC
Header: Poco/Data/ODBC/TypeInfo.h
Datatypes mapping utility class.
This class provides mapping between C and SQL datatypes as well as datatypes supported by the underlying database. In order for database types to be available, a valid conection handle must be supplied at either object construction time, or at a later point in time, through call to fillTypeInfo member function.
Class also provides a convenient debugging function that prints tabulated data to an output stream.
Member Functions: cDataType, fillTypeInfo, getInfo, print, sqlDataType, tryGetInfo
typedef std::map < int, int > DataTypeMap;
typedef Poco::NamedTuple < std::string, SQLSMALLINT, SQLINTEGER, std::string, std::string, std::string, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, std::string, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLINTEGER, SQLSMALLINT > TypeInfoTup;
typedef std::vector < TypeInfoTup > TypeInfoVec;
typedef DataTypeMap::value_type ValueType;
explicit TypeInfo(
SQLHDBC * pHDBC = 0
);
Creates the TypeInfo.
~TypeInfo();
Destroys the TypeInfo.
int cDataType(
int sqlDataType
) const;
Returns C data type corresponding to supplied SQL data type.
void fillTypeInfo(
SQLHDBC pHDBC
);
Fills the data type info structure for the database.
DynamicAny getInfo(
SQLSMALLINT type,
const std::string & param
) const;
Returns information about specified data type as specified by parameter 'type'. The requested information is specified by parameter 'param'. Will fail with a Poco::NotFoundException thrown if the param is not found
void print(
std::ostream & ostr
);
Prints all the types (as reported by the underlying database) to the supplied output stream.
int sqlDataType(
int cDataType
) const;
Returns SQL data type corresponding to supplied C data type.
bool tryGetInfo(
SQLSMALLINT type,
const std::string & param,
DynamicAny & result
) const;
Returns information about specified data type as specified by parameter 'type' in param result. The requested information is specified by parameter 'param'. Will return false if the param is not found. The value of result will be not changed in this case.