Re: ALTER PUBLICATION - Mailing list pgsql-admin

From David G. Johnston
Subject Re: ALTER PUBLICATION
Date
Msg-id CAKFQuwbW=fE2kkCn2rsdhVqYuMB=wD9MyKXfUrG+OG7t4m=kgQ@mail.gmail.com
Whole thread Raw
In response to ALTER PUBLICATION  (Lalith Tenneti <lalithkx@gmail.com>)
List pgsql-admin
On Tuesday, October 30, 2018, Lalith Tenneti <lalithkx@gmail.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.

pgsql-admin by date:

Previous
From: Lalith Tenneti
Date:
Subject: ALTER PUBLICATION
Next
From: nunks
Date:
Subject: Error code for "no partition or relation found for row"