Escape single quotes properly in string values when generating SQL statements