Mateusz Loskot wrote:
> Michał Nowotka wrote:
>> Having this piece of code:
>>
>> rowset<unsigned long> accounts = sql.prepare << string("select
>> distinct owner_ID_FK as konto from Simple_Node where ID=5");
>>
>> for (soci::rowset<unsigned long>::const_iterator nodeIterator =
>> nodeIDs.begin(); nodeIterator != nodeIDs.end(); ++nodeIterator)
>> {
>> //
>> }
>>
>> where and how should I put these inicators to avoid throwing exception?
>
> Michał,
>
> I think I see your point. I will check the problem myself at home
> tonight and see what's going on.
OK, I've played a bit with this issue and here is the conclusion:
Michał has found a serious gap in the SOCI interface and functionality.
1. There is (at least I haven't found it) no way to use rowset<T> with
queries may return null values. In such cases, the following error is
thrown:
error: Null value fetched and no indicator defined.
Here is simple test case:
soci::session sql(soci::postgresql, "dbname=test);
sql.begin();
sql << "drop table if exists tb1";
sql << "create table tb1 (id serial NOT NULL, name text)";
sql << "insert into tb1(name) values (\'mloskot\')";
sql << "insert into tb1(name) values (NULL)";
sql.commit();
typedef soci::rowset<std::string> rowset_type;
rowset_type rs = (sql.prepare << "select name from tb1");
for (rowset_type::iterator it = rs.begin(); it != rs.end(); ++it)
{
// irrelevant part
}
The error is expected to be thrown during 2nd iteration.
2. Use of indicators with rowset<T> is not supported.
error: Explicit into elements not allowed with rowset.
3. Use of boost::optional seems to be impossible:
rowset<boost::optional<std::string> > = ... ;
due to the fact that there are no exchange traits provided
for this combination. At least, Visual C++ 9.0 is not able to
instantiate any. Compilation fails.
The only thing I can say at this moment is that the problem
needs to be solved in near future.
Thanks to Michał for helping to find the "gap in the service" :-)
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users