Consider following code
Calendar calendar = Calendar.getInstance();
int currentFiscalYear = calendar.get( Calendar.YEAR );
query = "SELECT FIRST( amount_allocated ) FROM budget WHERE department_id = '" +
departmentId + "' AND fiscal_year = " + currentFiscalYear;
resultSet = statement.executeQuery( query );
if( resultSet.next() )
{
return true;
}
else
{
return false;
}
I execute this code on a table with folowing columns.
department_id, head_id, fiscal_year, amount_alloc, amount_remain
when I execute this code, on such records that none of them fullfills the
select condition, the resultSet.next() method still works and does not
return false, it still returns ture. But if I call result.wasNull() inside the if
block, after calling a getter method. the wasNull() returns true. Why the
resultSet returns ture even if no record is exists in the table for the
current year. Please guide.
Thanks.