Обсуждение: psql variable quoting

Поиск
Список
Период
Сортировка

psql variable quoting

От
Artacus
Дата:
I'm having quoting issues... or concatenation or just issues when trying
to use psql variables.

TRUNCATE TABLE :tbl;
COPY :tbl FROM xxxxx WITH CSV HEADER;

For xxxxx I want to do a concatenation of :import_path :tbl '.csv'
Obviously I can't have the spaces in it. If I remove the spaces, it
doesn't expand the variables.

I can set a import_file variable like so:
\set import_file '/tmp/:tbl.csv'
That expands properly but isn't quoted when used in the COPY command.

How do I do this?

Artacus