Skip site navigation (1) Skip section navigation (2)

Re: Interpolation of environment variables in SQL at runtime?

From: Joe Conway <mail(at)joeconway(dot)com>
To: Andy Gimblett <A(dot)M(dot)Gimblett(at)swansea(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Interpolation of environment variables in SQL at runtime?
Date: 2004-10-31 22:02:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Andy Gimblett wrote:
> Hopefully what I'm asking is fairly obvious.  But is it possible?  I
> can imagine some fairly unwiedly ways to do this involving
> preprocessing, but would involve jumping through lots of hoops, and
> I'd hope for a cleaner solution.  Environment variables seems the
> obvious "Unixy" approach...
> Surely people have hit this problem before?  How's it solved?

See plr_environ() in PL/R's pg_userfunc.c. You could probably rip it out 
and use it standalone with reasonable ease (or perhaps modify it to 
return a single requested environment variable).

Use it like this:

select value from plr_environ() where name = 'MANPATH';
(1 row)


In response to

pgsql-general by date

Next:From: Bruno LavoieDate: 2004-10-31 22:08:37
Subject: Suggested Triggers & Functions Naming Convention?
Previous:From: Tom LaneDate: 2004-10-31 21:14:52
Subject: Re: Daylight Savings Time handling on persistent connections

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group