I have a psql script that has lots of inserts, and I want one of the numbers I insert into a table to be relative to a specific number that I draw from a table.
I tried to do it as following:
select @max_a = max(a) + 1 from tableA;
insert into ... values (@max_a + 5)
but I get an error on the first select statement (ERROR: syntax error at or near "@").
I tried to replace it with
set @max_a = (select max(a) + 1 from tableA);
but that didn't work either (I get ERROR: syntax error at or near "@").
Any ideas?