From: Warren Young Date: March 17 2008 5:18am Subject: Re: Problem Handling Null Values List-Archive: http://lists.mysql.com/plusplus/7514 Message-Id: <47DDFF2F.2030506@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dustin Moore wrote: > mysqlpp::Null nullIntField = mysqlpp::null; > if (result.at(0)["Unit_id"] != nullIntField) { > // do something with int value > } 1. I don't see the purpose of nullIntField. You should be able to compare any Null to mysqlpp::null directly. 2. There's no need to give NullIsNull as the second argument to Null. It's already the default. 3. Since you're spelling "NullisNull" with a lowercase 'i', either you're using MySQL++ 2.x, which doesn't have the SQL null improvements in v3, or you haven't read the breakages chapter in the user manual. 4. result.at(0) further argues that this is MySQL++ 2.3 we're talking about, so one then wonders why you haven't tried upgrading to v3, which allows the much nicer subscripting syntax, even with the zeroth index. Taken together, the code for v3 should read: > On compile I receive: > error: ambiguous overload for ‘operator!=’ in > ‘mysqlpp::Row::operator[](const char*) const(((const char*)"Unit_id")) ! > = nullIntField’ > note: candidates are: operator!=(int, int) > note: operator!=(unsigned int, int) > note: operator!=(long int, int) > note: operator!=(long unsigned int, int) > note: operator!=(mysqlpp::longlong, int) > note: operator!=(mysqlpp::ulonglong, int) > note: operator!=(float, int) > note: operator!=(double, int) > > If I type cast "result.at(0)["Unit_id"]" to int then I get run time > errors about convert Null to int. How do I clear the ambiguity? > > Also, if there is no fixing my code, what is a good simple example of > handling nulls? > > Thanks, > Dustin Moore > me@stripped > >