Re: psql scripting tutorials

From: Kevin Hunter <hunteke(at)earlham(dot)edu>
To: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
Cc: Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql scripting tutorials
Date: 2008-09-11 15:55:47
Message-ID: 48C93F83.4010302@earlham.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 7:13am -0400 on Thu, 11 Sep 2008, Harald Fuchs wrote:
> Nice trick, but when I try the following variant:
>
> psql -v TEST=16 -c 'select :TEST as "input"'
>
> I get [a syntax error]

> This seems to be contrary to the psql manual page:

Nope. Take a look at the -c option. Specifically "Thus you cannot mix
SQL and psql meta-commands with this option."

You might try shell interpretation:

$ TEST=16; psql -c "select $TEST as \"input1\";"
$ TEST=16; echo "select $TEST as \"input1\";" | psql

Kevin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomasz Ostrowski 2008-09-11 15:59:52 Re: Autocommit, isolation level, and vacuum behavior
Previous Message Scott Marlowe 2008-09-11 15:55:28 Re: declare column update expression