Fix Incorrect var in SQL Loop

Fix Incorrect var in SQL Loop
Merge pull request #1247 from mkly/fix_area_global_flip_flop

Fix Incorrect var in SQL Loop