I am trying to declare a variable in PostgreSQL. No matter what I do, it's always a syntax error.
declare x integer := 1;
x := 1;
declare x := 1;
@declare x := 1;
Yes, I know variables only work in queries written in plpgsql. I've read this answer everywhere, but no explanation whatsoever on how to switch to it. Can please someone explain it to me in very simple terms?