chaitu chaitu
asked on
If any of the Items value is '1' FLAG SHOULD be set as 'Y'
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'
}
}
{
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'
}
}
If "FLAG" is a field in your database, you should consider doing this task in an sql update statement.
ASKER
"FLAG" is NOT a field in database
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";
}
//Code for " '1' FLAG SHOULD be set as 'Y'"
if( "1".equals(rs.getString(1)
FLAG="Y";
}
ASKER
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;;
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;
}
//Code for " '1' FLAG SHOULD be set as 'Y'"
if( "1".equals(rs.getString(1)
FLAG="Y";
break;
}
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;
}
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;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
>>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.