Re: psql access of user's environmental variables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Tilles <Paul(dot)Tilles(at)noaa(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: psql access of user's environmental variables
Date: 2007-05-03 14:43:28
Message-ID: 3846.1178203408@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Paul Tilles <Paul(dot)Tilles(at)noaa(dot)gov> writes:
> What I really want to do is the following:

> \set local_site `echo $FXA_LOCAL_SITE
> UPDATE table_name SET office_id = :local_site;

> This results in the message
> column "xxx" does not exist

Yes, because you have no quotes in the value of the variable, so that
update looks to the server like
UPDATE table_name SET office_id = xxx;

After some fooling around, the easiest way to get the needed quotes is
to embed them in the echo result:

\set local_site `echo "'$FXA_LOCAL_SITE'"`

BTW, does your psql really let you leave off the trailing ` like
that? Mine doesn't.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thorsten Kraus 2007-05-03 14:59:59 Stored procedure
Previous Message Andrus 2007-05-03 14:12:43 tuple concurrently updated