List:MySQL++« Previous MessageNext Message »
From:Dustin Moore Date:March 18 2008 1:24am
Subject:Re: Problem Handling Null Values
View as plain text  
On Sun, 2008-03-16 at 23:19 -0600, Warren Young wrote:
> 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:
> 
>      if (result[0]["Unit_id"] != mysqlpp::null) {
>          // do something with int value
>      }
> 
> Much cleaner, no?
> 

I downloaded, compiled and installed mysql++-3.0.0 without error.

My Code looks like this.
	#include <mysql++.h>
	...
	if (result.at(0)["Unit_id"] != mysqlpp::null) {
		// do something with int value
	}
	...


Building file: ../DataInterface/DataInterface.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/mysql -I/usr/include/mysql++ -O0 -g3 -Wall -c
-fmessage-length=0 `pkg-config --cflags gtkmm-2.4` `pkg-config --cflags
libglademm-2.4` -MMD -MP -MF"DataInterface/DataInterface.d"
-MT"DataInterface/DataInterface.d" -o"DataInterface/DataInterface.o"
"../DataInterface/DataInterface.cpp"
../DataInterface/DataInterface.cpp: In member function ‘bool
DataInterface::get(Food&)’:
../DataInterface/DataInterface.cpp:247: error: no match for ‘operator!=’
in ‘mysqlpp::Row::operator[](const char*) const(((const
char*)"Unit_id")) != mysqlpp::null’
/usr/include/mysql++/type_info.h:389: note: candidates are: bool
mysqlpp::operator!=(const mysqlpp::mysql_type_info&, const
std::type_info&)
/usr/include/mysql++/type_info.h:375: note:                 bool
mysqlpp::operator!=(const std::type_info&, const
mysqlpp::mysql_type_info&)
/usr/include/mysql++/type_info.h:361: note:                 bool
mysqlpp::operator!=(const mysqlpp::mysql_type_info&, const
mysqlpp::mysql_type_info&)
/usr/include/mysql++/const_string.h:210: note:                 bool
mysqlpp::operator!=(mysqlpp::const_string&, mysqlpp::const_string&)
make: *** [DataInterface/DataInterface.o] Error 1

/usr/local/lib$ ls -l *mysql*
lrwxrwxrwx 1 root root      15 2008-03-17 20:04 libmysqlpp.so ->
libmysqlpp.so.3
lrwxrwxrwx 1 root root      19 2008-03-17 20:04 libmysqlpp.so.3 ->
libmysqlpp.so.3.0.0
-rwxr-xr-x 1 root root 2349199 2008-03-17 20:04 libmysqlpp.so.3.0.0

/usr/local/include/mysql++$ ls -l
total 1540
-rw-r--r-- 1 root root    1804 2008-03-17 20:04 autoflag.h
-rw-r--r-- 1 root root    3989 2008-03-17 20:04 beemutex.h
-rw-r--r-- 1 root root    6933 2008-03-17 20:04 common.h
-rw-r--r-- 1 root root    3118 2008-03-17 20:04 comparable.h
-rw-r--r-- 1 root root   13367 2008-03-17 20:04 connection.h
-rw-r--r-- 1 root root    6893 2008-03-17 20:04 cpool.h
-rw-r--r-- 1 root root    1343 2008-03-17 20:04 custom.h
-rw-r--r-- 1 root root   12962 2008-03-17 20:04 datetime.h
-rw-r--r-- 1 root root   18377 2008-03-17 20:04 dbdriver.h
-rw-r--r-- 1 root root   11731 2008-03-17 20:04 exceptions.h
-rw-r--r-- 1 root root    5121 2008-03-17 20:04 field.h
-rw-r--r-- 1 root root    2926 2008-03-17 20:04 field_names.h
-rw-r--r-- 1 root root    2332 2008-03-17 20:04 field_types.h
-rw-r--r-- 1 root root   11642 2008-03-17 20:04 manip.h
-rw-r--r-- 1 root root    3822 2008-03-17 20:04 myset.h
-rw-r--r-- 1 root root    6006 2008-03-17 20:04 mysql++.h
-rw-r--r-- 1 root root   23094 2008-03-17 20:04 mystring.h
-rw-r--r-- 1 root root    5290 2008-03-17 20:04 noexceptions.h
-rw-r--r-- 1 root root   10210 2008-03-17 20:04 null.h
-rw-r--r-- 1 root root   11634 2008-03-17 20:04 options.h
-rw-r--r-- 1 root root    7875 2008-03-17 20:04 qparms.h
-rw-r--r-- 1 root root   27645 2008-03-17 20:04 querydef.h
-rw-r--r-- 1 root root   39580 2008-03-17 20:04 query.h
-rw-r--r-- 1 root root    8378 2008-03-17 20:04 refcounted.h
-rw-r--r-- 1 root root   12817 2008-03-17 20:04 result.h
-rw-r--r-- 1 root root   19168 2008-03-17 20:04 row.h
-rw-r--r-- 1 root root    5040 2008-03-17 20:04 sql_buffer.h
-rw-r--r-- 1 root root    5623 2008-03-17 20:04 sql_types.h
-rw-r--r-- 1 root root 1149416 2008-03-17 20:04 ssqls.h
-rw-r--r-- 1 root root   11690 2008-03-17 20:04 stadapter.h
-rw-r--r-- 1 root root    1729 2008-03-17 20:04 stream2string.h
-rw-r--r-- 1 root root    4389 2008-03-17 20:04 tcp_connection.h
-rw-r--r-- 1 root root    6652 2008-03-17 20:04 tiny_int.h
-rw-r--r-- 1 root root    3241 2008-03-17 20:04 transaction.h
-rw-r--r-- 1 root root    9912 2008-03-17 20:04 type_info.h
-rw-r--r-- 1 root root    3629 2008-03-17 20:04 uds_connection.h
-rw-r--r-- 1 root root   22279 2008-03-17 20:04 vallist.h
-rw-r--r-- 1 root root    3280 2008-03-17 20:04 wnp_connection.h

/usr/local/include/mysql++$ view mysql++.h
...
#define MYSQLPP_HEADER_VERSION MYSQLPP_VERSION(3, 0, 0)
...

Also

I used the [] operator instead of the at() function and received:
	error: no match for ‘operator[]’ in ‘result[0]’


Thread
Problem Handling Null ValuesDustin Moore17 Mar
  • Re: Problem Handling Null ValuesWarren Young17 Mar
  • Re: Problem Handling Null ValuesWarren Young17 Mar
    • Re: Problem Handling Null ValuesDustin Moore18 Mar
      • Re: Problem Handling Null ValuesWarren Young18 Mar
        • Re: Problem Handling Null ValuesDustin Moore19 Mar
          • Re: Problem Handling Null ValuesWarren Young19 Mar