[i/208] moving sql string to be generated only if needed