From e267def4f9f2e47402d72b56a45924f0bd2c0a18 Mon Sep 17 00:00:00 2001 From: randomdan Date: Mon, 3 Mar 2014 20:57:27 +0000 Subject: Adds native support for time_duration as a variable type Pass/retrieve boost::posix_time ptime and time_duration into/out of the db tier --- libodbcpp/param.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'libodbcpp/param.h') diff --git a/libodbcpp/param.h b/libodbcpp/param.h index 661d9b3..37f8d5a 100644 --- a/libodbcpp/param.h +++ b/libodbcpp/param.h @@ -5,6 +5,7 @@ #include #include #include "bind.h" +#include namespace ODBC { class Command; @@ -79,6 +80,19 @@ namespace ODBC { protected: Glib::ustring data; }; + class IntervalParam : public Param { + public: + IntervalParam() : Param() { } + IntervalParam(Command * c, unsigned int i) : Param(c, i) { bindLen = size(); } + virtual SQLSMALLINT ctype() const { return SQL_C_INTERVAL_DAY_TO_SECOND; } + virtual SQLSMALLINT stype() const { return SQL_INTERVAL; } + virtual SQLULEN size() const { return sizeof(SQL_INTERVAL); } + virtual SQLINTEGER dp() const { return boost::posix_time::time_res_traits::num_fractional_digits(); } + virtual const void * dataAddress() const { return &data; } + void operator=(const boost::posix_time::time_duration & d); + protected: + SQL_INTERVAL_STRUCT data; + }; class TimeStampParam : public Param { public: TimeStampParam() : Param() { } @@ -86,11 +100,9 @@ namespace ODBC { virtual SQLSMALLINT ctype() const { return SQL_C_TYPE_TIMESTAMP; } virtual SQLSMALLINT stype() const { return SQL_TYPE_TIMESTAMP; } virtual SQLULEN size() const { return sizeof(SQL_TIMESTAMP_STRUCT); } - virtual SQLINTEGER dp() const { return 0; } + virtual SQLINTEGER dp() const { return boost::posix_time::time_res_traits::num_fractional_digits(); } virtual const void * dataAddress() const { return &data; } - void operator=(const time_t & d); - void operator=(const struct tm * d) { data << *d; } - void operator=(const SQL_TIMESTAMP_STRUCT & d) { data = d; } + void operator=(const boost::posix_time::ptime & d); protected: SQL_TIMESTAMP_STRUCT data; }; -- cgit v1.2.3