[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

If any of the Items value is '1' FLAG SHOULD be set as 'Y'

Posted on 2007-08-01
8
Medium Priority
?
207 Views
Last Modified: 2010-03-30
     for(int k=0;k<itemsList.size();k++)
                        {
                              EmpItems empItems = (EmpItems) itemsList.get(k);
                              pstmt3.setString(1, empItems.getItemId());              
                                          
                              
                              ResultSet rs1= pstmt3.executeQuery() ;
                              while(rs1.next())
                              {
                              
                                    If any of the Items value is '1' FLAG SHOULD be set as 'Y'
                                    
                              }
                                    
                        }
0
Comment
Question by:chaitu chaitu
  • 3
  • 3
  • 2
8 Comments
 
LVL 5

Expert Comment

by:mkatmonkey
ID: 19609417
If "FLAG" is a field in your database, you should consider doing this task in an sql update statement.
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 19609455
"FLAG" is NOT a field in database
0
 
LVL 5

Expert Comment

by:mkatmonkey
ID: 19609884
Assuming that there's only one column in your result set:
//Code for " '1' FLAG SHOULD be set as 'Y'"
if( "1".equals(rs.getString(1)) ){
   FLAG="Y";
}
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 20

Author Comment

by:chaitu chaitu
ID: 19609916
rs.getString(1) should come either 0 or 1;if any of the item VALUE is 1 then it should be 'Y' so we should iterate all items;;
0
 
LVL 5

Expert Comment

by:mkatmonkey
ID: 19610229
I'm not sure what your asking. If you wanted to break the while loop if you find "Y" in your result set, just  use the break statement.

//Code for " '1' FLAG SHOULD be set as 'Y'"
if( "1".equals(rs.getString(1)) ){
   FLAG="Y";
   break;
}
0
 
LVL 11

Expert Comment

by:raj3060
ID: 19610583
boolena continueFlag = false;      
for(int k=0;k<itemsList.size();k++)
                        {
                              EmpItems empItems = (EmpItems) itemsList.get(k);
                              pstmt3.setString(1, empItems.getItemId());              
                                         
                             
                              ResultSet rs1= pstmt3.executeQuery() ;
                              while(rs1.next())
                              {
                             
                                  if( "1".equals(rs.getString(1)) ){
                                      continueFlag = true;                                      
                                  }                                    
                              }
                                    if(!continueFlag)
                                        break;
                        }
0
 
LVL 11

Accepted Solution

by:
raj3060 earned 1500 total points
ID: 19611711
BTW:

This should be iterating through all the fields:
                                  if( "1".equals(rs.getString(1)) ){
                                      continueFlag = true;                                      
                                  }
i.e.

int numOfColumns = # of Columns;
 for(int i = 1; i <= numOfColumns; i++)
{
           if( "1".equals(rs.getString(i)) ){
                        continueFlag = true;                                      
           }
}



0
 
LVL 11

Expert Comment

by:raj3060
ID: 19611729
Never mind:
>>rs.getString(1) should come either 0 or 1;if any of the item VALUE is 1 then it should be 'Y' so we should iterate all items

Didn't see that.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month19 days, 23 hours left to enroll

873 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