CREATE OR REPLACE FUNCTION public.fn_admin_list_course_email_templates(p_course_id integer)
 RETURNS TABLE(template_key text, language text, subject text, body_html text, body_text text, active boolean, updated_at timestamp with time zone)
 LANGUAGE sql
 STABLE
AS $function$
  SELECT
    template_key::text,
    language::text,
    subject,
    body_html,
    body_text,
    active,
    updated_at
  FROM public.course_email_templates
  WHERE course_id = p_course_id
  ORDER BY template_key, language;
$function$
;
