Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

How can I incorporate this 2nd query into my edit page?

I have a JSP page that performs an update to records in my db2 table.  This page's record variables are populated with a query to my db2 table.  The thing is, I need to query from a second table, in order to populate a dynamic drop down list.

How can I incorporate this 2nd query into my edit page?
0
g118481
Asked:
g118481
  • 5
  • 4
1 Solution
 
copyPasteGhostCommented:
just make 2 querys..
one for the update
and one to populate the drop down
Ghost
0
 
g118481Author Commented:
I was hoping to incorporate both queries into one.
0
 
copyPasteGhostCommented:
but they are doing two separate things? why would you want to make them into one?
or is there something I'm missing?
Ghost
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
g118481Author Commented:
ok, then give me an example of how to run two queries in the same edit form page.
In an edit page one must output the existing record variables for each text box, select box, etc. that is already in the record.
In the output of these in the form how do i break that output of variables and include the output of the 2nd query to the drop down list, as it is in the middle of the output of the variables of the 1st query?
0
 
copyPasteGhostCommented:
load the queries into 2 different resultSets and then use them
That's what I what I would do

use one of the resultsets to fill in the text box, select box
and the other result set to load the drop down list
Cheers,
Ghost
0
 
g118481Author Commented:
code example please
0
 
copyPasteGhostCommented:
rs = statm.executeQuery(sqlQueryString);
rs2 = statm.executeQuery(sqlQueryString2);

if(rs.next()) {
int count =1;
do {
  out.println("record " + count + " value " + rs.getString(1));
  count++;
}while(rs.next());

you can do what you want with the results from the resultset
same idea for the rs2

if(rs2.next()) {
out.print("<select name='selectBox'>");
do {
  out.println("<option name='" + rs.getString(1) + "' value='" + rs.getString(1) + "' />";
}while(rs.next());
out.print("</select>");

hope that helps,
Ghost
0
 
g118481Author Commented:
and what happens when the select list for query 2 is in the middle of your query 1 output?
0
 
copyPasteGhostCommented:
???wha??
why would you do that..
have two different select statments.. one for the drop down and another for the rest of the stuff
Ghost
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now