- Code: Select all
struct data {
int a;
int b;
};
std::vector< data > data_collection;
//...
Poco::Data::Session db( "SQLite", ":memory:" );
Statement( db ) << "INSERT INTO TABLE_A VALUES( ?1 )", use( data_collection ), now; // should insert into TABLE_A values of data::a
Statement( db ) << "INSERT INTO TABLE_B VALUES( ?1 )", use( data_collection ), now; // should insert into TABLE_A values of data::b
To insert data::a into the TABLE_A i'm using specialization of the TypeHandler template:
- Code: Select all
namespace Poco {
namespace Data {
template<>
struct TypeHandler< data_collection::value_type > {
typedef data_collection::value_type value_type;
static std::size_t size() { return 1; }
static void bind( std::size_t pos, const value_type& obj, AbstractBinder* pBinder ) {
TypeHandler< int >::bind( pos++, obj.a, pBinder); // inserts data::a
}
static void prepare( std::size_t, const value_type&, AbstractPreparation* ) {}
static void extract( std::size_t pos, value_type& obj, const value_type& defVal, AbstractExtractor* pExt ) {}
};
}
}
And now i have to insert data::b into the TABLE_B.
How can i do that since TypeHandler template is already specialized?
What is the best way to use the same data collection with different statements?
Thanks in advance





