Looping through 2 Result Sets - Not working-HELP!!

This code loops through my first result set fine.....so I take the first part number from the result set, do a second result set to bring back all part conditions associated with that part number and compare them to see if they are all the same. When it hits the second loop with the second result set, it only loops once. I know this because of my system.out.println only print once.....can someone see where I'm going wrong....thanks in advance....
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
DataSource ds = this.getDataSource();
HttpSession sess = req.getSession();
if (sess == null)
res.sendRedirect(/error.html");
else
synchronized(sess)
UtilParts part = (UtilParts)sess.getValue("UtilParts.PARTS");
String[] partNumbers = new String[10];
for(int index=0; index < partNumbers.length; index ++)
partNumbers[index] = req.getParameterValues("partNumber"+index)[0];
partNumbers[index] = partNumbers[index].trim();
String partDesc = req.getParameterValues("partdesc")[0].toUpperCase();
partDesc = partDesc.trim();
int rowsCounted = 0;
for(int index = 0 ; index < partNumbers.length; index ++)
if(partNumbers[index].equals(""))
rowsCounted ++;
Connection conn = null;
ResultSet resultSet = null;
ResultSet resultSetMultCond = null;
PreparedStatement getPartInfo = null;
Statement getMultPartCond = null;
String sqlMultCond = null;
String sql = null;
try
conn = ds.getConnection(id,pass);
conn.setReadOnly(true);
if(partDesc.equals(""))
sql = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE '";
boolean first = true;
for (int i=0; i < partNumbers.length; i++)
if (!partNumbers.equals(""))
if (!first)
sql += "%' OR #PART LIKE '";
sql += partNumbers;
first = false;
sql += "%' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC,#CONDS ORDER BY #PART";
getPartInfo=conn.prepareStatement(sql);
resultSet = getPartInfo.executeQuery();
if(!partDesc.equals(""))
String sqlDesc = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PDESC LIKE ? AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC ORDER BY #PART";
getPartInfo = conn.prepareStatement(sqlDesc);
getPartInfo.setString(1,partDesc + "%");
resultSet = getPartInfo.executeQuery();
Vector enum = new Vector();
int rowsadded = 0;
while (resultSet.next())
rowsadded += 1;
UtilParts utilityPart = new UtilParts();
String s = (String)resultSet.getString("#PART");
s = s.trim();
utilityPart.setPartNumber(s);
String t = (String)resultSet.getString("#PDESC");
t = t.trim();
utilityPart.setPartDesc(t);
int resultCount = 0;
int sameCond = 0;
String storeName = null;
String holdName = "No";
int i = resultSet.getInt("PCOUNT");
String cond;
if(i == 1)
String c = (String)resultSet.getString("#CONDS");
c = c.trim();
if(c.equals(""))
cond = "N/A";
else
cond = c;
utilityPart.setPartCondition(cond);
utilityPart.setPartCount(i);
else
sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = '" + s + "' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#CONDS ORDER BY #PART";
getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);
int row =0;
while(resultSetMultCond.next())
row += 1;
System.out.println("Row: " + row);
resultCount = resultSetMultCond.getInt("MCOUNT");
System.out.println("MCount: " + resultCount);
if(holdName.equals("No"))
System.out.println("You are in the no loop");
storeName = (String)resultSetMultCond.getString("#CONDS");
holdName = storeName;
sameCond += 1;
System.out.println("Same condition: " + sameCond);
System.out.println("StoreName: " + storeName);
System.out.println("HoldName: " + holdName);
else
storeName = (String)resultSetMultCond.getString("#CONDS");
if(holdName.equals(storeName))
sameCond += 1;
System.out.println("Same condition: " + sameCond);
System.out.println("StoreName: " + storeName);
System.out.println("HoldName: " + holdName);
resultSetMultCond.close();
getMultPartCond.close();
if(resultCount == sameCond)
System.out.println("resultcount equals samecount");
utilityPart.setPartCount(1);
utilityPart.setPartCondition("same conditions everywhree");
else
System.out.println("resultcount not equal samecount");
utilityPart.setPartCount(i);
utilityPart.setPartCondition("");
enum.addElement(utilityPart);
}//end of first while
if (rowsadded == 0 )
res.sendRedirect("/PartNotFound.html");
sess.putValue("PARTS",enum);
resultSet.close();
conn.close();
getServletConfig().getServletContext().getRequestDispatcher("/NextQuery.jsp").forward(req,res);
return;
catch (SQLException e1)
System.out.println(e1.getMessage());
e1.printStackTrace();
res.sendRedirect("/FindPartSQLError.htm");
}//end of synchronized session
}//end of else
}//end of method

Got the answer...changed my select statement in my second loop, did a group by CONDS which of course if they are all the same....the result set would only have one value therefore the loop will only execute once...took out the group by CONDS and ran fine....

Similar Messages

  • Loop through result set and delete row

    so here is what I need -
    I have a query that pulls rows from the Database through a stored procedure.(these are properties in an area)
    Before I start looping through the query, I need to check the distance between my current location and the property. If it less than 5 miles, only then should I display that property. The distance in miles will be chosen while submitting the search form.
    So is there a way to delete rows from the result set based on the criteria? Or
    Is there a better way to accomplish this? I am using the the google api to get the latitudes and longitudes. The other issue to keep in mind is the load time.
    Thanks

    You can do this the easy way or the hard way.  Depends on whether your condition that needs to be checked can be expressed in the form of a SQL where clause.  If it can, then do what BKBK suggested, and use a query of query to create a new resultset that only has the rows from the original resultset that don't meet your condition.
    If the calculation of the condition is more complex, then do a CFLOOP over the query and examine each row to see if you want to keep it or toss it.  if you want to toss it, the delete that row - there is a function in CFLIB.ORG called querydeleterow that should help you.  Or, you could just clear out the row's contents and then do the query of query as described in BKBK's post to create a new resultset that doesn't include the blank rows.

  • Looping through result set

    Hello, I am experience a heapdump while looping through a result set from a query I amr unning.
    Our system creates an instance of a transfer object representing one row in the result set for each row as it loops through. The result set brings back 36000 rows, so it is creating 36000 objects. As a result, a heapdump is occurring. What can be done to fix this error?

    even if it holds 360000 rows,
    I still think [zadok] idea is a great idea.
    you can get, for example first 1000 rows, cacluate it save result, and then get the next 1000 rows, is it make sense?
    if you still want to get it by one time, extend your vm mem, normal setting is 64M(I am not sure)

  • Secure Empty Trash Setting not working HELP!!!

    Im trying to turn off the secure empty trash I dont know how it got turned on
    but its not working
    Ive tried going to Finder > Preference > advanced > uncheck the secure empty box
    but it doesnt work it keeps asking me if im sure to delete the item
    I dont want secure empty trash i like keeping the files for a while just in case
    HELP please

    Click on the item in the Finder's sidebar with the house icon and verify that you are able to write to this folder in the Ownership & Permissions section of the Get Info window, and that it isn't locked; if it is already set this way and you get that error, open the Terminal in the /Applications/Utilities/ folder and run the following:
    mkdir ~/.Trash
    If you get a message stating that the folder exists, run the following:
    sudo chown $UID ~/.Trash
    chmod u+rwx ~/.Trash
    The first command in the second set will prompt you for your administrator password; nothing will appear in the Terminal window while it is being typed. In either case, click on the Finder icon in the Dock with the Control and Option keys pressed, and relaunch it.
    (55512)

  • Since I installed the new OS X Lion, the iCal syncing through iTunes is not working properly.

    Since I installed the new OS X Lion, the iCal syncing through iTunes is not working properly.
    When I sync my MacBook Pro with my iPhone and iPad, the events set in both devices (iPhone & iPad) are not transfered to the iCal on my labtop. Events created in both devices are transfered and copied betwen them when I sync them with the iTunes app (through the MacBook Pro) but they are not trasfered/copied into the labtop (iCal). The events created in the iCal (on my MacBook) are tranfered to the devices as two events on same hour. One, with the description created on the iCal, and the other as a New Event (no description). This is happening since I installed the new OS X Lion last week.
    I file a report and talked with an Apple Support Representative, but they could not help me. They have not receive any other reports on this matter. Do someone has confronted this issue. I need to find out how to solve this problem.
    Regards,
    JAD

    Hi Sydness,
    Thank you very much for your help. It just worked fine. I have 4 macs in my company for 25 years (one is updated each year), and it is the first time I could not solve a problem for weeks. It gave me the opportunity to join this great community.
    Charles
    Sydness wrote:
    I reset my SyncServices and the calendar sync worked perfectly after that.
    I followed the instructions found here:
    http://support.apple.com/kb/TS1627?viewlocale=en_US
    Mac OS 10.7.1 - MacBook

  • [PWS0007] Operation result set not found.

    Hi,
    I am working with java,db2 on AS/400.
    When I am using my application with multiple users hitting the submit at the same time,I am getting
    the following error:
    Exception: [PWS0007] Operation result set not found. Cause . . . . . : The handle specified for the operation result set to be filled, returned, or used as the based on result set is not found for the server.
    Recovery . . . : Correct the operation result set handle and do the function again.
    Can anybody please tell me what could be the problem?
    Thanks in advance.

    problem could be
    1)Resulsets objects are not closing after getting data (like end of rRrsultSet while loop)
    2)it is better close statements and connection objects also.

  • Purchase Order Goods Receipt quantity tolerance setting not working.

    Team,
    We are using the IS-Oil solution, ECC 6.0 REL 605 SP LEVEL 009 .
    The issue that I have is as follows:
    Purchase Order Goods Receipt quantity tolerance setting not working, I had set up a 10% tolerance on QTY received in the GR process via the PIR and also the Purchase Value Key in the  material master and also changed the message to a warning in OMCQ for message number M0722.
    I  had performed a similar configuration and master data maintenance on a different NON IS-OIL client install and it worked fine.
    I believe it is the IS-OIL component in the Inventory update portion of the GR process that is causing the error.
    I have searched for OSS notes, however they mention that there is no solution.
    Setting the PO line item as Unlimited will not be best practice for the business and will not be used.
    Has anyone come across this issue? and how was it resolved, your help and guidance will be greatly appreciated.
    Thanks

    Hello,
    Please check the Tolerance levels in O588 
    Also you can use the BAdI OIB_QCI_ROUND_QTY: A new method, CHECK_TOLERANCE
    Best Regards,
    R.Brahmankar

  • ABAP routine - looping a result set from table.

    I am trying to access a table and pass the resulting rows to an internal table.
    However, before passing, I need to do some data manipulation on one of the columns of the table and then pass it.
    If I didn't have to do this, I could have just said
    INTO CORRESPONDING FIELDS OF TABLE
    But since I have do data manipulation, I cannot do this. This is what I am doing now.
    SELECT * FROM /BI0/QEMPLOYEE WHERE JOB = '1234' AND DATETO = '99991231'.
    MOVE /BI0/QEMPLOYEE-EMPLOYEE TO INT_EMP-EMPN.
    MOVE /BI0/QEMPLOYEE-JOB TO STR1.
    STR2 = STR1 + 0(4)
    SEARCH STR2 FOR ' ' STARTING AT 1 ENDING AT 1.
    IF SY-SUBRC EQ 0.
    REPLACE ' ' WITH '0' INTO STR2.
    ENDIF.
    MOVE STR2 TO INT_EMP-FAC.
    But this will move only one row. How can I move all the rows? Is there a loop that I can use? I can see a loop for internal tables but I need to loop the result set and then send it. I posted this question twice but haven't gotten the right answer.
    Thanks.

    Hi,
    Are you trying to write the code in Update Routine or a Start Routine.?
    If you want to update all the records, you can use the start routine.
    So you need to use a loop for doing all the records.
    If you are using a Update routine then you dont have to use the loop.
    But here I recommend the Start Routine is the best choice.
    Here is a document which can be helpful for you:
    http://bluestonestep.com/component/option,com_docman/task,doc_download/gid,13/
    Happy Tony

  • The two finger cycle through apps does not work?

    Hello,
    I don'nt know what is wrong, but it seems that the two finger gesture allowing to cycle through apps does not work for me. I  am using a standard mac Bluetooth mouse. 
    Can anyone help me with this?
    Thank you
    Sebastien  Dion
    from Quebec city, Canada

    Download a free app. It reauthorizes your device for use of your apple id.

  • Urgent: OSB FTP polling is not working, help!!!

    hi all,
    I am doing an onsite poc on customer site, and configuring and proxy service on OSB(11.1.1.5) using ftp , but it just not working, not picking files in the specified folder, no error message. seems it can connect and login, but just not picking the files, though I set the mask to *.*, poll interval 3 seconds. any tricky? someone can help?
    I've read all the documents abt ftp transport, and I can configure file proxy, ftp business service successfully.
    thank you very much in advanced.

    no log still, for DEBUG.
    error will throw in log only if I set the wrong user/password.
    seems it connected to the ftp server, but just not picking the files there. I don't know why. I doubted it's the problem of the path setting, but it's the same for phsical path and relative path. not working.
    help...........

  • After upgrading to iOS 5 I cannot enter to mail (outlook exchange ),contact did not open, general settings - mail contact did not work.help me

    After upgrading to iOS 5 I cannot enter to mail (outlook exchange ),contact did not open, general settings - mail contact did not work.help me

    Hi,
    the settings are gone, i guess. But even worse, I cannot get the iPad2 to play Full HD thru the Apple digital AV adaptor using apps that support  (and advertise this), like AVPlayer HD. This definiteley used to work before one of the last iOS upgrades. (I am now at 5.1.1).

  • When i go in my settings on my ipod touch 3gen it says no wi-fi as in i cant connect to any wi-fi at all i tried to restore but did not work HELP PLEASE

    when i go in my settings on my ipod touch 3gen it says no wi-fi as in i cant connect to any wi-fi at all i tried to restore but did not work HELP PLEASE

    See:
    iOS: Wi-Fi or Bluetooth settings grayed out or dim
    If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
    Apple Retail Store - Genius Bar

  • Panasonic .MOV files only play audio no video in Premiere Elements 11??? Not Working Help

    Panasonic .MOV files only play audio no video in Premiere Elements 11??? Not Working Help

    It all depends on the codec the file uses, Karli.
    What model of camcorder is this video coming from?
    Are you working on a Mac or a PC? Have you got the latest version of Quicktime, per the program requirements? When you started your project, did you select the settings for a DSLR at 720p? This is a vital step since it will activate the components your computer will need to work with many of these types of files.
    BY THE WAY, KARLI--
    PLEASE do not post the same question more than once on this forum! You've already got a thread going with this same question and several responses posted. It's very confusing when you post the same question a second time and start a whole new discussion.

  • My MacBook Air won't turn on? I have to dropped it but earlier in the day I got a notification about a full single drive. I have tried the ideas in the communities but its still not working, help!

    My MacBook Air won't turn on? I have to dropped it but earlier in the day I got a notification about a full single drive. I have tried the ideas in the communities but its still not working, help!

    See this article:
    http://support.apple.com/kb/ht3964
    Find the section that applies to your computer, and follow the instructions.
    Shut down the computer.
    Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
    On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
    Release all the keys and the power button at the same time.
    Press the power button to turn on the computer. 
    Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.

  • I cant open my ipad after i turned on the voice in accessibility i have a passcode and i tried to enter my password but it not working. help me please

    i cant open my ipad after i turned on the voice in accessibility i have a passcode and i tried to enter my password but it not working. help me please..
    i updated my ipad in ios 6

    Turn off VoiceOver
    1. Press the Home button
    2. Tap Settings.
    3. Then double-tap Settings.
    4. Tap General.
    5. Then double-tap General.
    6. Use three fingers on the screen to scroll to Accessibility
    7. Tap Accessibility.
    8. Then double-tap Accessibility
    9. Tap VoiceOver
    10. Then double-tap VoiceOver.
    11. Tap "On" next to VoiceOver
    12. Then double-tap "On" to turn it off.

Maybe you are looking for