function Generate_GetSQL_Where to Sub
removed unused references
fix