Re: how to create a sequence in a stored proc?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: how to create a sequence in a stored proc?
Дата
Msg-id CAHyXU0zUaKPEd=uKFvtJAaoGkfP4whzZqcMP4xNB+QtsAsf1ZQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: how to create a sequence in a stored proc?  ("J.V." <jvsrvcs@gmail.com>)
Список pgsql-general
On Fri, Apr 27, 2012 at 11:35 AM, J.V. <jvsrvcs@gmail.com> wrote:
> Right, I understand that fully, and have used SQL inside a stored proc
> before, but in this case as I mentioned, I need to first do a select from a
> table to get a max value, store that in a variable and then use that
> variable in a create sequence sql statement.
>
> so I need to construct a string that contains the create sequence statement
> and execute that string, at least this is the way it is done in Oracle.
>
> I do not know how to use a variable in a create sequence statement in
> PostgreSQL.

oh I see. try this:


postgres=# do
$$
declare
  s int default 3;
begin
  execute 'create sequence v start ' ||  s;
end;
$$ language plpgsql;
DO

merlin

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

Предыдущее
От: Filip Rembiałkowski
Дата:
Сообщение: Re: empty role names in pg_dumpall output
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: how to create a sequence in a stored proc?