I'm having a hard time here with pl-pgsql syntax.
here's the code:
DO $$
DECLARE
dia_semana INT := CAST(EXTRACT(DOW FROM CURRENT_DATE)as INT);
dia INT := CASE WHEN dia_semana = 0 THEN dia := 7;
WHEN dia_semana = 1 THEN dia := 6;
WHEN dia_semana = 2 THEN dia := 5;
WHEN dia_semana = 3 THEN dia := 4;
WHEN dia_semana = 4 THEN dia := 3;
WHEN dia_semana = 5 THEN dia := 2;
WHEN dia_semana = 6 THEN dia := 1;
BEGIN
COPY(SELECT CURRENT_DATE + dia)
TO '/tmp/dump.sql';
END $$;
raises the error:
'LINE 4: dia INT := CASE WHEN dia_semana = 0 THEN dia := 7;'
with cursor on ":" "dia:= 7". Already tried a normal assignment "dia = 7" without success. Can someone please lend me a hand here?
tnx.