Re: Accessing environment variables from psql (SOLVED) - Mailing list pgsql-general

From Andreas Seltenreich
Subject Re: Accessing environment variables from psql (SOLVED)
Date
Msg-id 874qef1kcj.fsf@gate450.dyndns.org
Whole thread Raw
In response to Re: Accessing environment variables from psql (SOLVED)  ("Leif B. Kristensen" <leif@solumslekt.org>)
Responses Re: Accessing environment variables from psql (SOLVED)  ("Leif B. Kristensen" <leif@solumslekt.org>)
List pgsql-general
Leif B. Kristensen writes:

> So, the problem is solved, sort of. It may also be prudent to save the
> old pwd and return there when the work is done:
>
> leif=> \set olddir `echo $PWD`
> leif=> \set importdir `echo $IMPORTDIR`
> leif=> \cd :importdir
> leif=> \i test.sql
> leif=> \cd :olddir

You can concatenate values using \set. So using

    \set importfile :importdir /test.sql
    \i :importfile

you won't have to mess with $PWD.

regards,
Andreas

pgsql-general by date:

Previous
From: Benjamin Smith
Date:
Subject: Lost in Foreign Key land
Next
From: Brian K Boonstra
Date:
Subject: Note: Compiling on Windows with free Microsoft compilers