Passing parameters into an in-line psql invocation

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Passing parameters into an in-line psql invocation
Date: 2011-06-02 16:58:23
Message-ID: 482E80323A35A54498B8B70FF2B87980049420A878@azsmsx504.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi:

I'd like to pass a parameter into an inline psql call that itself calls an sql script, something like...

psql mydb -c "\i thesqlscript foo"

Where"foo" is the value I want to pass in.

Just as good would be the ability to sniff out an environment variable from within the sql script ("thesqlscript" in the example above). In perl, I would use $ENV{VARNAME}. Is there something like that in Postgres SQL?

V8.3.4 on Linux (upgrading to v9 very soon).

Thanks for any ideas !

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-06-02 16:58:51 Re: Need suggestion
Previous Message Merlin Moncure 2011-06-02 16:41:14 Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs