Hello.
Sorry for the late reply, I had been very busy this week.
I were using the rowset object since I had to process several rows.
I have modified your example so you can see the issue.
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);
soci::rowset<soci::row> rs = (sql.prepare << "SELECT x FROM t1");
for (rowset::const_iterator it = rs.begin(); it != rs.end(); ++it)
{
soci::row const& row = *it;
uu = row.get<unsigned int>("x");
}
cout << " uu " << uu << endl;
Thanks,
Best Regards.
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
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web. Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users