You should try doing something like this instead of looping back through the result set for every record...
String strquery1 = null;
String strquery2 = "SELECT * FROM SGT_INV_TMP";
// *******WHY IF I PUT ResultSet rst2 = stmt.executeQuery(strquery
ResultSet rst1 = null;
ResultSet rst2 = stmt.executeQuery(strquery
Statement stmt2 = con.createStatement();
while ( rst2.next() ) {
%>
<tr>
<%
//not sure if this is the right column name in your where, may have to change
strquery1 = "SELECT * FROM SGT_WH_LOOKUP WHERE Inv_DistWHCode = '" + rst2.getString("Inv_DistWH
rs1 = stmt2.executeQuery(strquer
if (rs1.next()){
%>
<td><%=rst2.getString("Inv
<%}%>
</tr>
<%
}
%>
If your DB supports it, here is an even better way to get it all in one select statement:
sql = "SELECT * FROM SGT_INV_TMP WHERE Inv_DistWHCode IN (SELECT Inv_DistWHCode FROM SGT_WH_LOOKUP)"
Joe
Main Topics
Browse All Topics





by: fargoPosted on 2006-05-22 at 03:45:36ID: 16733138
because you are using same statement for executing the queries. Use two seperate statements. Moreover, always remember to close rs, stmt and conn in finally clause.
I don't understand your requirement much, but u can also make it in single query by using sql joins etc.