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

  • Home
  • SEARCH
  • 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 7535027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:11:07+00:00 2026-05-30T06:11:07+00:00

I wrote a script in which it retrieves data from a database and i

  • 0

I wrote a script in which it retrieves data from a database and i have given the option to the user whether they would like to search again. @Andrey helped me fix the problem with the user answering ‘Yes’ or ‘No’ to the question.

goAgain = true;
while goAgain
    pdbSearch = input('Enter your PDB Code: ', 's');
    curs = fetch(exec(conn, ['SELECT * FROM cath_2_wo_dup WHERE pdbcode = ' '''' pdbSearch '''']));
    fprintf('Results Successful! \n');
    results = curs.Data % prints the data out

    % ----------------------
    % User option to search again
    % -----------------------

    res = input('Would you like to search for another pdb?', 's');
    goAgain = isequal(upper(res),'YES');
end

However, I have another query that i would like to ask. How do i allow the data that has been retrieved first to be displayed in the workspace, before giving the option to the user of searching again?

Although it shows the results in the command window, i would like to see my results that i have queried in the Variable Editor before searching again. It only displays the variables in the workspace after I have entered ‘No’ in the command window.

Please advise.

  • 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-30T06:11:08+00:00Added an answer on May 30, 2026 at 6:11 am

    The workspace browser shows you the existing variables after you enter ‘No’ because that is when the while loop ends. If during execution of a script, function or, as in your case a loop, the browser is updated, this would be too expensive. And by expensive I mean CPU-intensive: just like if you use fprintf() in a loop…

    If you want to play with the intermediate values, then set a break point at

    res = input('Would you like to search for another pdb?', 's');
    

    and when the while-loop reaches there, you will see the workspace browser updated. I do not know if this helps you.

    If you want to be able to browse previous choices after you enter ‘No’, then use a cell array to store the past search results:

    goAgain = true;
    pastResuls=struct();
    reultsCounter=1;
    while goAgain
      pdbSearch = input('Enter your PDB Code: ', 's');
      curs = fetch(exec(conn, ['SELECT * FROM cath_2_wo_dup WHERE pdbcode = ' '''' pdbSearch '''']));
      fprintf('Results Successful! \n');
      results = curs.Data % prints the data out
      pastResuls(reultsCounter).results=results;
      pastResuls(reultsCounter).pdbSearch=pdbSearch;
    
      % ----------------------
      % User option to search again
      % -----------------------
    
      res = input('Would you like to search for another pdb?', 's');
      goAgain = isequal(upper(res),'YES');
      reultsCounter=reultsCounter+1;
    

    end

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

Sidebar

Related Questions

I have Python script which retrieves data from an API in JSON format (at
I wrote this script which counts occurrences of particular pattern in a given file.
I have wrote this little script which generates a nice random password. The problem
Possible Duplicate: jQuery: Return data after ajax call success I wrote a script which
I wrote a sample html which retrieves the JSON from servlet and displays. But
I wrote a trivial bash script which dumps a random line from a file
I have a database in PostgreSQL which is named DATA in all caps. When
I wrote a bash script which renames MythTV files based upon data it receives.
I wrote this quick script which updates the database when moving the location of
I recently wrote a script which queries PyPI and downloads a package; however, the

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.