On Tuesday, October 30, 2018, Lalith Tenneti <
lalithkx@xxxxxxxxx> 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.