Overview
Features
Download
Documentation
Community
Add-Ons & Services

NULL Data columns

Please post support and help requests here.

NULL Data columns

Postby rd » 19 Jun 2007, 10:36

Hi,

I'm using a Poco::Data::RecordSet to retrieve data from a SQLite database.
Is there a way to detect that a column contains NULL?
It seems to me Poco::Data always inserts a default value for NULL data.

Thanks,

Ronny
rd
 
Posts: 19
Joined: 16 Jun 2007, 15:30

Re: NULL Data columns

Postby alex » 19 Jun 2007, 13:55

> I'm using a Poco::Data::RecordSet to retrieve data from a SQLite database.
> Is there a way to detect that a column contains NULL?
> It seems to me Poco::Data always inserts a default value for NULL data.

Unfortunately, currently there is no way to check for NULL from RecordSet. I will look into this issue and try to squeeze it in for 1.4.

Alex
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: NULL Data columns

Postby alex » 20 Jun 2007, 03:13

The code for null insertion/detection is in SVN repository. Currently, it only works for SQLite. This is how to use it:

Code: Select all

ses << "CREATE TABLE NullTest (i INTEGER)", now;
ses << "INSERT INTO NullTest VALUES(:i)", use(null), now;
RecordSet rs(ses, "SELECT * FROM NullTest");
rs.moveFirst();
assert (rs.isNull("i"));
assert (rs["i"] == 0);


When fetching data, nulls are still replaced with default values, but RecordSet now provides a function to check whether underlying value in the database is null.

Have a nice Poco time ;-)

Alex
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron