Am 22.12.2012 um 01:02 schrieb Mateusz Loskot:

> On 21 December 2012 23:26, Philipp Kraus <[email protected]> wrote:
>> 
>> I try to get a table field from a Postgresql database, which is a "bool" 
>> type, but I get this
>> compiler error:
>> 
>> instantiated from 'soci::details::into_type_ptr soci::into(T&) [with T = 
>> bool]
>> error: incomplete type 'soci::details::exchange_traits<bool>' used in nested 
>> name specifier
>> 
>> I create a prepare statement:
>> 
>> soci::statement l_stm = (l_sql.prepare << "select history from 
>> simulation.simulation where id= :id", soci::into(l_history), 
>> soci::use(m_id));
>> 
>> with l_history is defined as: bool l_history=false;
>> 
>> Should I use another datatype and convert it to a C++ boolean?
> 
> Boolean is a tricky type indeed.
> 
> ATM, you need to go through integer:
> 
> sql << "create table soci_test(val boolean)";
> int i1 = 0;
> sql << "insert into soci_test(val) values(:val)", use(i1);
> int i2 = 7; // random initial value
> sql << "select val from soci_test", into(i2);
> assert(i2 == 0) ;
> sql << "update soci_test set val = true";
> sql << "select val from soci_test", into(i2);
> assert(i2 == 1) ;

Works well, thanks

Phil
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to