Externalizing SQL queries

Signed-off-by: udara <udara@alliontechnologies.com>