Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:49:52+00:00 2026-06-15T08:49:52+00:00

I use Soci to make database queries. Now I need to have a custom

  • 0

I use Soci to make database queries. Now I need to have a custom resultset class that will wrap around soci::rowset. I cannot get it work in the way my code are below simply because copy constructor is private in soci (not supported according to source file). How can I accomplish having wrapper with list of soci::rows (hereby typedef-ed to Row) without complicated code? Any design or direction on how to go about is appreciated

my header file

typedef soci::row Row; 


class ResultSet
{
public:
    ResultSet();
    ~ResultSet();
    void Copy(soci::rowset<soci::row>& rs);

    Row GetNextRow();
    bool HasRows();

private:
    soci::rowset<soci::row> m_rows;
    soci::rowset_iterator<soci::row> m_iterator;
    bool m_isAccessed;//if first access on row is done
};

source file

ResultSet::ResultSet() {
    m_isAccessed=false;
}

ResultSet::~ResultSet() {

}

Row ResultSet::GetNextRow() {
    if(m_isAccessed) {
        m_iterator++;//increment row
        m_isAccessed=true;
    }
    return *m_iterator;
}

bool ResultSet::HasRows() {
    return m_iterator!=m_rows.end();//it have not reached the end yet;
}

void ResultSet::Copy(soci::rowset<soci::row>& rs) {
    m_rows = rs;
    m_iterator = rs.begin();//put it at row 1
}

and here is how I use in ExecuteQuery function of connection. m_session is soci::session

void ConnectionMgr::ExecuteQuery(wxString& sql, ResultSet& rs) {
    try { 
        soci::rowset<soci::row> rsInternal = m_session.prepare<<sql.ToStdString();
        rs.Copy(rsInternal); 
    }
    catch (std::exception const& e) {
        m_error = wxString::Format(wxT("SqlQuery close error:%s\n"), e.what());
    }
}

example of how I want to use the class later

wxString sql = wxT("-- a query\n SHOW DATABASES;"); 
                ResultSet rs;
                m_conn->ExecuteQuery(sql, rs);
                while(rs.HasRows())
                {
                    wxString name = wxString(rs.GetNextRow().get<std::string>(0));
                    //work with name here
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:49:54+00:00Added an answer on June 15, 2026 at 8:49 am

    SOCI have many limitation and undertaking such task seems to be impossible without modifying sources which would mean you have to maintain changes yourself (unless the developers accepts patches which is a probability).

    Since I use wxWidgets, I decided to revive databaselayer as wxDatabase and will use that and maintain it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use scenario is pretty simple: I have a desktop only application that could be
use case example I have a servlet that is receiving login requests. If a
I'm using soci for making my app interact with databases and currently I use
I have a compilation error when using rowset of tuples with the latest soci
Use Elixir and have two entities -- Voter and Candidate -- with many to
use javascript or other method ? have any recommendation?
Use Eclipse Classic with ADT plugin. Tried to make project from existing example of
Use case: You have 2-3 files displayed in your MacVim window(s). You press ctrl+Q
Use case: I find a piece of code that I do not understand at
Use case is to have a server connect to thousands of users email accounts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.