add result NULL checks to sql_queries