psql variable quoting - Mailing list pgsql-general

From Artacus
Subject psql variable quoting
Date
Msg-id 48EDB56F.7070605@comcast.net
Whole thread Raw
List pgsql-general
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

pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: review db dump script and difference between pg_dump & pg_dumpall
Next
From: Julius Tuskenis
Date:
Subject: Re: [pgadmin-support] problem with check constraints