From: Warren Young Date: April 4 2011 9:07pm Subject: Re: Mysql++ AVOID NULL Columns!! :) List-Archive: http://lists.mysql.com/plusplus/9311 Message-Id: <4D9A3313.6080607@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 4/3/2011 5:33 AM, Raymond Boettcher wrote: > > should work: > if(string(vbasketballevent[b]["tf_station_num"]) != mysqlpp::null ) If vbasketballevent is a mysqlpp::Result, there's no reason at all you need to convert Result[][] to std::string here. If it's an STL container of SSQLSes instead, the only reason you might have had to do that is that your SSQLS wasn't defined using mysqlpp::Null wrappers on the columns that can contain SQL NULL. That wasn't possible pre-MySQL++ 3.0, but it is now, so any reason you had for doing that once has gone away. Either way, the check against mysqlpp::null shouldn't need to go through any explicit conversions. MySQL++ fully preserves NULL-ness on values now if you use data types that can preserve it. Getting back to Eric's issue, you are correct, Raymond, that comparing to the C NULL constant is wrong, and that part of the fix is to compare against MySQL++'s mysqlpp::null value. > I even use > mysqlpp::sql_int_unsigned, etc for some of my variables Are you using mysqlpp::sql_int_unsigned_null, etc., too? That's shorthand for mysqlpp::Null, etc. > trying to compare the information with C++'s int has also given me > bad compile issues in the past. I'm not sure if this is still > true... Depending on the data types of the columns in use, yes, using the lib/sql_types.h typedefs can give better results than using textbook C++ types. That header knows things about the MySQL C API and about the platform MySQL++ was built on that aren't expressed in plain old C++ data types.