Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2006-04-15 05:19:30


Steve Hutton wrote:
> The idea is that to select all rows, you fetch within a loop. The
> vector gets resized to contain the number of rows returned.
>
> const int BATCH_SIZE = 30;
> std::vector<int> valsOut(BATCH_SIZE);
> Statement st = (sql.prepare << "select value from numbers",
> into(valsOut));
> st.execute();
> while (st.fetch())
> {
> std::vector<int>::iterator pos;
> for(; pos != valsOut.end(); ++pos)
> {
> cout << *pos << '\n';
> }
> }
>
> http://soci.sourceforge.net/doc/statements.html

How abouit something like:

sql::statement query;
query << "select value from numbers";

sql::rowset< int > rows(query);
cout << "found = " << rows.size() << endl;

std::vector< int > values;
std::copy( rows.begin(), rows.end(), values );

Multi-item row searches could use tuple:

sql::rowset< int, std::wstring, int > rows( query );
std::tr1::tuple< int, std::wstring, int > value = rows.begin();

- Reece
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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