data definition within plpgsql

From: hamann(dot)w(at)t-online(dot)de
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: data definition within plpgsql
Date: 2019-01-28 10:17:56
Message-ID: wolfgang-1190128111756.A0227604@noten19.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I tried this code (to be inserted within a larger psql script)

do $_$
declare
next int;
begin
select max(id) + 1 into next from items;
execute 'create temp sequence tmp_ids start $1' using next;
end
$_$ language plpgsql;

but that reports a syntax error near $1.
What is the proper way of doing that?

Best regards
Wolfgang Hamann

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Schweikle 2019-01-28 10:19:40 Re: logical replication problem
Previous Message Thomas Schweikle 2019-01-28 10:12:18 logical replication problem