# Poco::Data::ODBC

# class Utility

Library: Data/ODBC
Package: ODBC
Header: Poco/Data/ODBC/Utility.h

## Description

Various utility functions

## Member Summary

Member Functions: cDataType, dataSources, dateSync, dateTimeSync, dbmsName, dbmsVersion, driverName, driverODBCVersion, driverVersion, drivers, isError, mapInsert, sizeOf, sqlDataType, sqlGetInfo, timeSync

## Types

### DSNMap

typedef std::map < std::string, std::string > DSNMap;

### DriverMap

typedef DSNMap DriverMap;

## Member Functions

### cDataType

static int cDataType(
int sqlDataType
);

Returns C data type corresponding to supplied SQL data type.

### dataSources

static DSNMap & dataSources(
DSNMap & dsnMap
);

Returns DSN-description map of available ODBC data sources.

### dateSync

static void dateSync(
Date & dt,
const SQL_DATE_STRUCT & ts
);

Transfers data from ODBC SQL_DATE_STRUCT to Poco::DateTime.

### dateSync

template < typename T, typename F > static void dateSync(
T & d,
const F & ds
);

Transfers data from ODBC SQL_DATE_STRUCT container to Poco::DateTime container.

### dateSync

static void dateSync(
SQL_DATE_STRUCT & ts,
const Date & dt
);

Transfers data from Poco::Data::Date to ODBC SQL_DATE_STRUCT.

### dateSync

template < typename C > static void dateSync(
std::vector < SQL_DATE_STRUCT > & ds,
const C & d
);

Transfers data from Poco::Data::Date vector to ODBC SQL_DATE_STRUCT container.

### dateTimeSync

static void dateTimeSync(
Poco::DateTime & dt,
const SQL_TIMESTAMP_STRUCT & ts
);

Transfers data from ODBC SQL_TIMESTAMP_STRUCT to Poco::DateTime.

### dateTimeSync

template < typename T, typename F > static void dateTimeSync(
T & dt,
const F & ts
);

Transfers data from ODBC SQL_TIMESTAMP_STRUCT container to Poco::DateTime container.

### dateTimeSync

static void dateTimeSync(
SQL_TIMESTAMP_STRUCT & ts,
const Poco::DateTime & dt
);

Transfers data from Poco::DateTime to ODBC SQL_TIMESTAMP_STRUCT.

### dateTimeSync

template < typename C > static void dateTimeSync(
std::vector < SQL_TIMESTAMP_STRUCT > & ts,
const C & dt
);

Transfers data from Poco::DateTime to ODBC SQL_TIMESTAMP_STRUCT.

### dbmsName

static std::string dbmsName(
const ConnectionHandle & db
);

Returns the back end DBMS name.

### dbmsVersion

std::string dbmsVersion(
const ConnectionHandle & db
);

Returns the back end DBMS version.

### driverName

std::string driverName(
const ConnectionHandle & db
);

Returns the driver name.

### driverODBCVersion

std::string driverODBCVersion(
const ConnectionHandle & db
);

Returns the driver ODBC standard version.

### driverVersion

std::string driverVersion(
const ConnectionHandle & db
);

Returns the driver version.

### drivers

static DriverMap & drivers(
DriverMap & driverMap
);

Returns driver-attributes map of available ODBC drivers.

### isError

static bool isError(
SQLRETURN rc
);

Returns true if return code is error

### mapInsert

template < typename MapType, typename KeyArgType, typename ValueArgType > static typename MapType::iterator mapInsert(
MapType & m,
const KeyArgType & k,
const ValueArgType & v
);

Utility map "insert or replace" function (from S. Meyers: Effective STL, Item 24)

### sizeOf

template < typename T > static constexpr SQLINTEGER sizeOf();

Returns size of the data type.

### sizeOf

template < typename T > static constexpr SQLINTEGER sizeOf(
const T & param45
);

Returns size of the data type.

### sqlDataType

static int sqlDataType(
int cDataType
);

Returns SQL data type corresponding to supplied C data type.

### sqlGetInfo

static std::string sqlGetInfo(
const ConnectionHandle & db,
SQLUSMALLINT type
);

Returns the requested info about the DBMS or ODBC driver. On error, returns "unknown".

### timeSync

static void timeSync(
Time & dt,
const SQL_TIME_STRUCT & ts
);

Transfers data from ODBC SQL_TIME_STRUCT to Poco::DateTime.

### timeSync

template < typename T, typename F > static void timeSync(
T & t,
const F & ts
);

Transfers data from ODBC SQL_TIME_STRUCT container to Poco::DateTime container.

### timeSync

static void timeSync(
SQL_TIME_STRUCT & ts,
const Time & dt
);

Transfers data from Poco::Data::Time to ODBC SQL_TIME_STRUCT.

### timeSync

template < typename C > static void timeSync(
std::vector < SQL_TIME_STRUCT > & ts,
const C & t
);

Transfers data from Poco::Data::Time container to ODBC SQL_TIME_STRUCT vector.

## Variables

### MS_SQL_SERVER_DBMS_NAME

inline static const std::string MS_SQL_SERVER_DBMS_NAME = "Microsoft SQL Server"s;