On Tue, 2011-01-04 at 19:29 +0100, NeDark wrote:
> I'm using a mysql database with soci.
> 
> In the database I have a column of type UNSIGNED INT but soci only let
> me get its value with the type INT.
> 
> The type (SIGNED) INT, both in mysql and in C++, has a minimum value of
> -2147483648 and  a maximum value of 2147483647.
> 
> The type UNSIGNED INT, both in mysql and in C++, has a minimum value of
> 0 and a maximum value of 4294967295.
> 
> So if a number is greater than 2147483647, the returned value would be
> incorrect.
> 
> However, soci only let me to get that value as INT, I have tried with
> UNSIGNED INT, UNSIGNED LONG; LONG LONG, UNSIGNED LONG LONG, and even
> with STRING (to convert to long long using strtoll) without luck. Soci
> always throws the error std::bad_cast.
> 
> Is there any way to get the column value successfully?

Hi,
which version are you using?
this works for me on git head and 3.0
(but note that 3.0 does not have support for unsigned int, only unsigned
long which is 64 bit on my system)

session sql(mysql, "db=test user=jtaylor password='...'");
sql << "CREATE TABLE IF NOT EXISTS t1 (b int unsigned, x bigint
unsigned)";
sql << "DELETE FROM t1";
unsigned long uu = ~0;
cout << " uu " <<  uu << endl;
sql << "INSERT INTO t1 (b,x) VALUES (0,:uu)", use(uu);
sql << "SELECT x FROM t1", into(uu);
cout << " uu " <<  uu << endl;

Best Regards,
Julian Taylor


Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to