From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | hamann(dot)w(at)t-online(dot)de |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: data definition within plpgsql |
Date: | 2019-01-28 10:20:35 |
Message-ID: | CAFj8pRB72r7_gMTvBVXgMwAkWQO2Cfxpy=EOwOUXymQERhg9Uw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi
po 28. 1. 2019 v 11:18 odesílatel <hamann(dot)w(at)t-online(dot)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
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2019-01-28 10:23:52 | Re: data definition within plpgsql |
Previous Message | Thomas Schweikle | 2019-01-28 10:19:40 | Re: logical replication problem |