Reputation: 89
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
.
Upvotes: 0
Views: 5398
Reputation: 15355
Perhaps you want to use current_setting
:
SET my_vars.movie_plot = 'test';
INSERT INTO movie(plot) VALUES (current_setting('my_vars.movie_plot'));
Upvotes: 1