Hello PlusPlus Mailing List!,
Actually, I'm kinda new to using mailing lists, so I replied to all only because I wasn't
certain if the reply should go back to plusplus@stripped or to the specific
user. I hope this doesn't get me spammed... Anyhow, moving on...
I've had this problem and I've been using MySQL++ for quite some time. I think at
this point in development there are members mysqlpp::null and is_null functions that can
be used to test for it. When I started using Mysql++ this wasn't true and often lead
to program crashes, etc.
I think?? Don't quote me, should work:
if(string(vbasketballevent[b]["tf_station_num"]) != mysqlpp::null )
I have found that comparing using components of mysqlpp against DB information tends to
give better results. I even use mysqlpp::sql_int_unsigned, etc for some of my
variables only because 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...
However, I recommend you do exactly as I've done since I started using this library and go
into MySQL Administrator, edit the table and check the "Not Null" field and clear and
default to a zero charactor string or 0 (integers, etc) for the default value if it
doesn't do it automatically when you apply the "Not Null" settings to the table.
This will ensure that strings are set to "" integers are set to 0, dates are set to
0000-00-00 00:00:00, etc. Unless you have some strange reason that you need a field
to be set to null. I just take Null out of the equation altogether. In
everything that I've ever written that uses mysql++, I've never found one instance to use
I did lookup a syntax for making the modification yourself but it has to be done with
every column you want to never be set to Null...
ALTER TABLE `Database`.`Table` MODIFY COLUMN `ColumnName` VARCHAR(45) NOT NULL;
Of course VARCHAR being the field type and maybe able to be omitted and just specify "NOT
NULL" since the entry already exists and omitting it should leave the field type the
same. If you creating the column for the first time just remember to tack "NOT NULL"
to the end of it.
I generally create all my tables for the first time using MySQL Administrator, so its
become habit to ensure that check mark is checked off. If my program happens to
crash on such an instance, usually a quick check of the tables leads me back to the "Not
I hope this helps. I rarely get a chance to comment on a list like this, but this is
one of the few things that made me pull my hair out one day, so I feel your pain...
--- On Sat, 4/2/11, Jonathan Wakely <mysql@stripped> wrote:
From: Jonathan Wakely <mysql@stripped>
Subject: Re: Actually it was this one.
To: "Eric Sepich" <sepotovich@stripped>
Date: Saturday, April 2, 2011, 5:32 PM
On 2 April 2011 22:02, Eric Sepich wrote:
> cout << string(vbasketballevent[b]["tf_station_num"]) << endl;
> Sorry about that. I have to take my last email back. Most of the time
> everything is fine but once in a while there seems to be some problem
> with vbasketballevent[b]["tf_station_num"].
> I think perhaps it might be NULL. How would I check and prepare an if
> statement? Could I use
> if(string(vbasketballevent[b]["tf_station_num"]) != NULL) ?????
> I've been struggling to get a debugger set up on Linux for months now. I
> can't seem to find one that operates as well as Microsoft Visual C++ Express
> so I have been debugging on Windows and running the program on Linux.
Run the program in gdb, when it segfaults type "where" to see where it crashed.
There are some GUID front ends to GDB listed at
http://sourceware.org/gdb/wiki/GDB%20Front%20Ends but it's easiest
just to use GDB. There's not setting up necessary.