I'm trying to set up an function that analyzes tables on the weekends.
create or replace function public.sp_analyze(t text)
returns void as
$$
BEGIN
if to_char(current_Date,'dy') = 'fri' THEN
--RAISE NOTICE '%', t;
execute 'vacuum analyze' || t
end if;
end;
$$
LANGUAGE plpgsql SECURITY DEFINER;
Is there a way to execute my analyze command without throwing errors?
This is my error:
ERROR: 42601: syntax error at or near "end"