I am using MySQL++ 1.7.27 on Windows with Visual C++ 7.1 (Visual Studio
.NET 2003). This same problem occurs with both MySQL 4.1 and 5.0 beta.
I have queries of the form:
<Query_object> << "select sum(field_value) where <where_clause>";
try{
<Result_object> = <Query_object>.store();
} catch (BadQuery er) {
// code here
}
// other checking to be certain got 1 and only 1 row
<Result::iterator_object> = <Result_object>.begin();
<Row_object> = *<Result::iterator_object>;
float_value = <Row_object>[0]; // <Row_object>[0] contains value
returned for sum(field_value)
My problem is that sometimes the sum() returns NULL (not 0.0). If I
directly assign the value to float_value, the program crashes with a
Microsoft Visual C++ Runtime Library abnormal program termination.
I need to be able to test the value of <Row_object>[0] before the
assignment and appropriately handle a NULL value. I tried:
if(!<Row_object>[0].is_null())
{ // handle successful one here
}
The program still abnormally terminates. Does the is_null() function
work properly? I looked in the MySQL++ source code and did not see where
the value of _null in coldata.h is being set.
Please let me know how to successfully test for NULL in a column of a
Row object. Thank you.
Jo Ellen