4848#include " Poco/Data/ODBC/Utility.h"
4949#include " Poco/DateTime.h"
5050#include " Poco/Any.h"
51+ #include " Poco/DynamicAny.h"
5152#include " Poco/Exception.h"
5253#include < map>
5354#ifdef POCO_OS_FAMILY_WINDOWS
@@ -97,6 +98,11 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
9798 bool extract (std::size_t pos, Poco::UInt64& val);
9899 // / Extracts an UInt64.
99100
101+ #ifndef POCO_LONG_IS_64_BIT
102+ bool extract (std::size_t pos, long & val);
103+ // / Extracts a long.
104+ #endif
105+
100106 bool extract (std::size_t pos, bool & val);
101107 // / Extracts a boolean.
102108
@@ -121,6 +127,9 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
121127 bool extract (std::size_t pos, Poco::Any& val);
122128 // / Extracts an Any.
123129
130+ bool extract (std::size_t pos, Poco::DynamicAny& val);
131+ // / Extracts a DynamicAny.
132+
124133 void setDataExtraction (Preparation::DataExtraction ext);
125134 // / Set data extraction mode.
126135
@@ -158,6 +167,7 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
158167 if (isNull (pos)) return false ;
159168
160169 poco_assert (typeid (T) == _rPreparation[pos].type ());
170+
161171 val = *AnyCast<T>(&_rPreparation[pos]);
162172 return true ;
163173 }
@@ -193,6 +203,63 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
193203 return true ;
194204 }
195205
206+ template <typename T>
207+ bool extractImpl (std::size_t pos, T& val)
208+ // / Utility function for extraction of Any and DynamicAny.
209+ {
210+ ODBCColumn column (_rStmt, pos);
211+
212+ switch (column.type ())
213+ {
214+ case MetaColumn::FDT_INT8 :
215+ { Poco::Int8 i = 0 ; extract (pos, i); val = i; return true ; }
216+
217+ case MetaColumn::FDT_UINT8 :
218+ { Poco::UInt8 i = 0 ; extract (pos, i); val = i; return true ; }
219+
220+ case MetaColumn::FDT_INT16 :
221+ { Poco::Int16 i = 0 ; extract (pos, i); val = i; return true ; }
222+
223+ case MetaColumn::FDT_UINT16 :
224+ { Poco::UInt16 i = 0 ; extract (pos, i); val = i; return true ; }
225+
226+ case MetaColumn::FDT_INT32 :
227+ { Poco::Int32 i = 0 ; extract (pos, i); val = i; return true ; }
228+
229+ case MetaColumn::FDT_UINT32 :
230+ { Poco::UInt32 i = 0 ; extract (pos, i); val = i; return true ; }
231+
232+ case MetaColumn::FDT_INT64 :
233+ { Poco::Int64 i = 0 ; extract (pos, i); val = i; return true ; }
234+
235+ case MetaColumn::FDT_UINT64 :
236+ { Poco::UInt64 i = 0 ; extract (pos, i); val = i; return true ; }
237+
238+ case MetaColumn::FDT_BOOL :
239+ { bool b; extract (pos, b); val = b; return true ; }
240+
241+ case MetaColumn::FDT_FLOAT :
242+ { float f; extract (pos, f); val = f; return true ; }
243+
244+ case MetaColumn::FDT_DOUBLE :
245+ { double d; extract (pos, d); val = d; return true ; }
246+
247+ case MetaColumn::FDT_STRING :
248+ { std::string s; extract (pos, s); val = s; return true ; }
249+
250+ case MetaColumn::FDT_BLOB :
251+ { Poco::Data::BLOB b; extract (pos, b); val = b; return true ; }
252+
253+ case MetaColumn::FDT_TIMESTAMP :
254+ { Poco::DateTime b; extract (pos, b); val = b; return true ; }
255+
256+ default :
257+ throw DataFormatException (" Unsupported data type." );
258+ }
259+
260+ return false ;
261+ }
262+
196263 bool isNullLengthIndicator (SQLLEN val) const ;
197264 // / The reason for this utility wrapper are platforms where
198265 // / SQLLEN macro (a.k.a. SQLINTEGER) yields 64-bit value,
0 commit comments