| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Lalith Tenneti <lalithkx(at)gmail(dot)com> |
| Cc: | "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: ALTER PUBLICATION |
| Date: | 2018-10-31 00:35:06 |
| Message-ID: | CAKFQuwbW=fE2kkCn2rsdhVqYuMB=wD9MyKXfUrG+OG7t4m=kgQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
On Tuesday, October 30, 2018, Lalith Tenneti <lalithkx(at)gmail(dot)com> wrote:
> Hi All,
>
> I am trying to run ALTER PUBLICATION ABC ADD TABLE <variable>. The
> variable is being set in a SELECT statement beforehand. But the ALTER
> statement adds the literal variable name. Is there anyway to acheive this?
> The reason is I do not want to hard code the table names.
>
> =============
>
> SQL doesn’t have variables and <variable> is not valid psql syntax. If
> you are doing this in pl/pgsql you will need to use EXECUTE and dynamic SQL
> and inject the variable into the statement string using format(stmt,
> variable) where stmt = “... ADD TABLE %I”
>
> David J.
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | nunks | 2018-10-31 01:03:23 | Error code for "no partition or relation found for row" |
| Previous Message | Lalith Tenneti | 2018-10-31 00:28:56 | ALTER PUBLICATION |