[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-plusplus
Subject:    problem with NULL value
From:       Ryan Gilfether <gilfetherr () pxi ! com>
Date:       2001-07-19 16:12:25
[Download RAW message or body]

when I execute the below code:

query << "SELECT MAX(access) AS access FROM permission WHERE doc_id=" <<
doc_id << " AND group_id=" << proj_id;

res = query.store();
i = res.begin();
row = *i;

if(row["access"] == NULL) // if(res.begin() == res.end())
{
	cout << endl << "found no access for realm id" << endl;
	return 0;
}
else
{
	cout << endl << "found realm permission " << row["access"];
	return (int)row["access"];
}


A result is always stored in row[] reguardless if the query really
returns a result. Sometimes this query should find anything, but MySQL++
will give row["access"] a value of NULL, and res.size() is never 0, even
if no match was found in the database. The problem is that in my if
statement, comparing row["access"]==NULL does not work, neither does
using 'if(res.begin() == res.end())' because something is being returned
even though it shouldnt be. The code always goes staight to the else
statement, and if the value is NULL it prints 'found realm permission
NULL'. I can't figure out how to compare this to a NULL value. 

Any help would be greatly appreciated.


-- 
Ryan Gilfether
Software Engineer
Praxis, Inc.
www.pxi.com
(703)837-8400 x5412

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic