Boost logo

Boost :

From: Phil Nash (phil.nash.lists_at_[hidden])
Date: 2006-10-05 08:20:06


> >> Row r;
> >> sql << "select * from ex2", into(r);
> >>
> >>> // Columns may be accessed by position...
> >>> std::cout << r[0].as<long>() << "\t ";
> >>
> >> SOCI equivalent: r.get<long>(0)
> >
> > I consider this a small abstraction mismatch: you apply the index to the row and
> > then you convert the field value to a C++ type. By the way, in this case
> > operator[] is the natural way to express indexing, so I believe that operator
> > overloading should be preferred.
>
> I agree, only and only if elements of a sequence can be
> identified only by index.
> In SOCI, when working with Row representation the situation is
> different - elements of Row can accessed *also* via name,
> what's natural in DBMS, where columns are named.
> So, SOCI interface is consistent and intuitive in this case:
>
> r.get<long>(0)
> r.get<long>("column1)

What about:

r[0].as<long>()
r["column1"].as<long>()

Regards,

[)o
IhIL..


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk