0

I read the Poco::Data User Manual and there is mentioned that the library has support for multiple result sets. There is example for this support in Multiple Data Sets section of the manual.

typedef Tuple<std::string, std::string, std::string, int> Person;
Person pHomer, pLisa;
int aHomer(42), aLisa(10), aBart(0);

session << "SELECT * FROM Person WHERE Age = ?; "
    "SELECT Age FROM Person WHERE FirstName = 'Bart'; "
    "SELECT * FROM Person WHERE Age = ?",
    into(pHomer, 0), use(aHomer),
    into(aBart, 1),
    into(pLisa, 2), use(aLisa),
    now;

But this example in only for one of the supported ways for fetching data with the library. There is second way for fetching data in the RecordSets, Iterators and Rows section.

Statement select(session); // we need a Statement for later RecordSet creation
select << "SELECT * FROM Person", now;

// create a RecordSet 
RecordSet rs(select);
std::size_t cols = rs.columnCount();

// print all column names
for (std::size_t col = 0; col < cols; ++col)
    std::cout << rs.columnName(col) << std::endl;

// iterate over all rows and columns
for (RecordSet::Iterator it = rs.begin(); it != rs.end(); ++it) 
    std::cout << *it << " ";

I have a wrapper around Poco::Data which uses the second way for fetching data and I have to extend it to support multiple result sets. I wonder is it possible and how to fetch multiple result sets with RecordSet interface?

Afterwords:

The multiple result sets are result of stored procedure call and because of this, it is not possible just to use multiple Statement objects for each select.

bobeff
  • 3,543
  • 3
  • 34
  • 62

1 Answers1

2

It is definitely possible to deal with multiple result sets that are returned from a stored procedure within a single statement. See eg. this test (executed here); the downside is that you have to know up front what the returned data looks like, unlike with RecordSet which is generic and can provide output without having any prior knowledge about the returned data structure.

Unfortunately, it is not currently possible to access multiple data sets using RecordSet. However, since RecordSet is implemented in terms of Statement, adding such feature should not be too hard.

Hope this helps.

Alex
  • 5,159
  • 4
  • 25
  • 33
  • Unfortunately for a generic wrapper around *Poco::Data* I cannot know what the returned data looks like in advance. Do you think that that will accept such a feature request? – bobeff May 04 '17 at 07:47
  • Sure, the feature request is accepted. The implementation timeframe is undefined, though. – Alex May 04 '17 at 16:52