Re: user defined variables - Mailing list pgsql-general

From Joel Burton
Subject Re: user defined variables
Date
Msg-id JGEPJNMCKODMDHGOBKDNKEHCCPAA.joel@joelburton.com
Whole thread Raw
In response to Re: user defined variables  (Moritz Sinn <moritz@freesources.org>)
Responses Re: user defined variables
List pgsql-general
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Moritz Sinn
> Sent: Friday, May 24, 2002 11:21 AM
> To: Nigel J. Andrews
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] user defined variables
>
>
> "Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
>
> > On 24 May 2002, Moritz Sinn wrote:
> > >
> > > hi,
> > >
> > > isn't it possible to define own environment vars?
> > >
> >
> > Did I miss something?
> >
> > I'd answer with:
> >
> >     Errrrr.......yeeeeees.
> >
> > Except I've got this distinct feeling I must have missed something.
> >
> > What is it you're trying to achieve other than setting
> environment variables
> > which is shell specific?
>
> well, i mean i want to make a value available under a certain name, for
> the whole db session.
> i want to do something like "UID=4545323667424;" and then be able to say
> "SELECT * FROM USER WHERE uid=UID;"
>
> But SET only accepts predefined environment variables.

In the psql client, you can set a variable with the "\set" command, or using
"--set" at startup. So "psql --set UID=xxxx" will let you use the the UID as
"SELECT * FROM USER WHERE uid= :UID".

Will this work for you?

- J.

Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant


pgsql-general by date:

Previous
From: Moritz Sinn
Date:
Subject: Re: user defined variables
Next
From: "Olonichev Sergei"
Date:
Subject: Re: How to add big amounts of data into database?