Adding sql to xml program logic