psql variable quoting

From: Artacus <artacus(at)comcast(dot)net>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: psql variable quoting
Date: 2008-10-09 07:40:31
Message-ID: 48EDB56F.7070605@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Julius Tuskenis 2008-10-09 07:50:39 Re: problem with check constraints
Previous Message hubert depesz lubaczewski 2008-10-09 07:24:08 Re: review db dump script and difference between pg_dump & pg_dumpall