Re: data definition within plpgsql

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: data definition within plpgsql
Дата
Msg-id CAFj8pRB72r7_gMTvBVXgMwAkWQO2Cfxpy=EOwOUXymQERhg9Uw@mail.gmail.com
обсуждение исходный текст
Ответ на data definition within plpgsql  (hamann.w@t-online.de)
Список pgsql-general
Hi

po 28. 1. 2019 v 11:18 odesílatel <hamann.w@t-online.de> napsal:


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;

the parameter can be used only with statements with execution plan (DDL has not execution plan).

you should to use execute format('create temp sequence tmp_ids start %s", next);

Regards

Pavel Stehule
 
end
$_$ language plpgsql;

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

Best regards
Wolfgang Hamann


В списке pgsql-general по дате отправления:

Предыдущее
От: Thomas Schweikle
Дата:
Сообщение: Re: logical replication problem
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: data definition within plpgsql