[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] Interpolation of environment variables in SQL at runtime?
From:       Joe Conway <mail () joeconway ! com>
Date:       2004-10-31 22:02:58
Message-ID: 41856112.6040005 () joeconway ! com
[Download RAW message or body]

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';
            value
---------------------------
  /usr/local/pgsql-dev/man:
(1 row)

Joe

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic