I'm trying to declare a text variable and insert it into my movie table.
This is what I'm doing:
DECLARE movie_plot TEXT;
movie_plot := '{test}';
INSERT INTO movie(plot) VALUES (movie_plot);
It gives me this error:
ERROR: syntax error at or near "TEXT"
LINE 1: DECLARE movie_plot TEXT;
^
SQL state: 42601
Character: 20
I already checked some solved questions similar to mine and this sintax seems correct. I saw that I could use the WITH to solve the problem, but i would like to use the DECLARE.
DECLARE(and thus variables) can only be used inside PL/pgSQL code not in SQL