There are two parts of solution,
Part 1: To refresh the data.
You can use execute(find.data) or execute(first.set) to refresh the session. You may code as follows,
Part 2: Prevention of display of records wth flag = yes.
you can use query.extension = "table.flag = No". Please check the syntax as im not sure about it.
Else you can use following code,
if table.flag = yes then
For performance reason, use query.extension
The above methods should work , let me know if you face any problem.