Solved

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

Posted on 2004-04-28
9
146 Views
Last Modified: 2010-04-01
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
Comment
Question by:g118481
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10942731
just make 2 querys..
one for the update
and one to populate the drop down
Ghost
0
 
LVL 1

Author Comment

by:g118481
ID: 10948227
I was hoping to incorporate both queries into one.
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10948773
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
 
LVL 1

Author Comment

by:g118481
ID: 10949062
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10949548
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
 
LVL 1

Author Comment

by:g118481
ID: 10951568
code example please
0
 
LVL 13

Accepted Solution

by:
copyPasteGhost earned 100 total points
ID: 10951664
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
 
LVL 1

Author Comment

by:g118481
ID: 10952036
and what happens when the select list for query 2 is in the middle of your query 1 output?
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10952312
???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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache server configuration 7 80
maven project in eclipse 11 57
reflection example 3 92
best tutorial on log4j and logging for servlets/jsp codes 1 63
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now