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 546173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:50:20+00:00 2026-05-13T10:50:20+00:00

My dilemma is that I am losing my ResultSet from the primary table when

  • 0

My dilemma is that I am losing my ResultSet from the primary table when accessing a foreign key table. I need to save the results from the first table query while I query another table.

Scenerio:
I am implementing a recipe database system. Each recipe can have 1 to many ingredients. To resolve the 1 to many relationship, I created a separate table for the ingredients.

I have a table of recipes:

  ID_Recipe: primary key, integer;   
  Recipe_Title: CHAR(128);

And a table of ingredients:

ID_Ingredient:  PRIMARY KEY, INTEGER;  
ID_Recipe:  INTEGER NOT NULL;  
Ingredient_Title: CHAR(64)  

In my program, I have a recipe object that contains a vector of ingredients:

struct Ingredient
{
  int ID;
  int recipe_ID;
  std::string title;
};

struct Recipe
{
  int ID;
  std::string title;
  std::vector<Ingredient> recipe_ingredients;
};

In order to perform a for each iteration on a recipe in the table, I must load it from the database. To complete the recipe, I have to load in all of the ingredients associated with the recipe.

The problem is that when I load in the ingredients, I lose the result set of the recipes. The MySQL Connector C++ can only handle one result set at a time. I have had no luck in copying the results either (when the table size grows, I may not want to load in the entire results).

So, how can I maintain a cursor or pointer to the recipe table while I search and load from the ingredient table?

Here is what I want to do:

  1. For each recipe in the table do:
  2. Read recipe result row data into
    Recipe variable.
  3. Use recipe ID to select all
    ingredients where Recipe.ID_Recipe =
    Ingredient.ID_Recipe.
  4. Load results from ingredient table
    into vector of Recipe variable.
  5. Pass recipe object to call-back
    function.
  6. Advance to next recipe in the table.
  7. End-for

Thanks in advance for any suggestions.
(I’m using MySQL, MySQL Connector C++, Visual Studio 2008 – C++)

  • 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-05-13T10:50:20+00:00Added an answer on May 13, 2026 at 10:50 am

    AFAICT, there’s nothing in the MySQL Connector/C++ doc indicating that opening a second ResultSet invalidates the first one. Please post the code you use to process the rows. You may be doing something that closes the first ResultSet prematurely.

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

Sidebar

Related Questions

I'm running into a bit of dilemma at the moment in that I need
I'm facing a dilemma (!). In a first scenario, I implemented a solution that
My dilemma is that I need to compile a large amount of projects and
To describe my dilemma, let me first start with an example problem (stolen from
The dilemma: I have options that need to store pricing data. Each option can
My dilemma: I'm passing my function a string that I need to then perform
I have a dilemma where to store secret tokens that I receive from twitter.
I have the following dilemma with two elements (menu items) that I need to
I have a dilemma that I've encountered before. What's the best in terms of
The dilemma I'm using a before_filter in my controller that restricts access to admins.

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.