Re: psql scripting tutorials

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: psql scripting tutorials
Date: 2008-09-11 11:13:51
Message-ID: pusks76ikw.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <Pine(dot)GSO(dot)4(dot)64(dot)0809110111250(dot)244(at)westnet(dot)com>,
Greg Smith <gsmith(at)gregsmith(dot)com> writes:

> On Tue, 9 Sep 2008, Artacus wrote:
>> Can psql access environmental variables or command line params?

> $ cat test.sql
> select :TEST as "input";
> $ psql -v TEST=16 -f test.sql
> input
> -------
> 16
> (1 row)

Nice trick, but when I try the following variant:

psql -v TEST=16 -c 'select :TEST as "input"'

I get

ERROR: syntax error at or near ":"
LINE 1: select :TEST as "input"

This seems to be contrary to the psql manual page:

These assignments are done during a very early stage of start-up...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-09-11 11:24:33 Re: No error when column doesn't exist
Previous Message Peter Eisentraut 2008-09-11 10:38:17 Re: external query VS user function