Re: How to define variables in psql scripts?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Kynn Jones <kynnjo(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to define variables in psql scripts?
Date: 2006-01-31 15:20:34
Message-ID: 43DF8042.6010405@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kynn Jones wrote:
> << kj314159265358979 >>
>
> 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?

You can use psql variables
http://www.postgresql.org/docs/8.1/static/app-psql.html#APP-PSQL-VARIABLES

Be careful with quoting issues though.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message P. Scott DeVos 2006-01-31 15:21:46 plpython error logs
Previous Message Guido Neitzer 2006-01-31 15:19:35 Re: verifying database integrity - fsck for pg?