I just created a test object, although with a simpler SQL, and it behaved as expected.
This thread is about a similar problem. The recommended solution is to not use modified SQL; I did not have the problem even though I used modified SQL, but it might be worth a try for you.
Joe
joepeters (BOB member since 2002-08-29)