Re: psql variables

From: ptjm(at)interlog(dot)com (Patrick TJ McPhee)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: psql variables
Date: 2005-03-25 18:32:27
Message-ID: 3aj3prF6ba6tgU1@uni-berlin.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <4235B688(dot)8000407(at)blueseacommunications(dot)com>,
Paul Cunningham <paul(at)blueseacommunications(dot)com> wrote:
% I use a bash script (similar to following example) to update tables.
%
% psql -v passed_in_var=\'some_value\' -f script_name ....
%
% Is it possible to pass a value back from psql to the bash script?

If you run it like this

$(psql -v passed_in_var=\'some_value\' -f script_name)

and arrange for all the script output to be in the form

var1="value 1" var2="value 2"
var3="value 3" ...

then var1, var2, etc will be set in bash (or ksh, or the posix shell).
Note that there are no spaces around the equals signs.
--

Patrick TJ McPhee
North York Canada
ptjm(at)interlog(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Sugalski 2005-03-25 18:34:08 Re: plperl doesn't release memory
Previous Message Jeff Amiel 2005-03-25 18:21:28 Re: Persistent data per connection