Re: How to define variables in psql?

From: <kynn(at)panix(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to define variables in psql?
Date: 2006-01-31 13:35:03
Message-ID: 200601311335.k0VDZ3A22493@panix3.panix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

From: A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com>
Date: Jan 31, 2006 8:20 AM
Subject: Re: [NOVICE] How to define variables in psql?
To: pgsql-novice(at)postgresql(dot)org

am 31.01.2006, um 7:17:17 -0500 mailte kynn(at)panix(dot)com folgendes:
>
> I know that one can store multiple psql commands and SQL statements in
> a separate "script" file, and then "source" the script file, e.g. with
> the \i command.
>
> My question is, can I define variables in such a script file?
> E.g. can I do something like the following unix-shell-like script?
>
> -- beginning of script
>
> DB=frobozz
> DIR=/foo/bar/baz/quux

something like this:?

\set DIR /home/kretschmer/
\set file :DIR foobar.sql

\set DB FOOBAR

\i :file

\echo "done with " :DB

Yes, exactly. Thanks.

kj

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas 2006-01-31 14:32:46 Re: Upgrade to PG 8 before starting major development?
Previous Message A. Kretschmer 2006-01-31 13:20:48 Re: How to define variables in psql?