Re: [SQL] \set

From: Christian Kratzer <ck(at)cksoft(dot)de>
To: Jie Liang <jie(at)stbernard(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] \set
Date: 2004-05-12 10:13:24
Message-ID: 20040512120015.E61036@vesihiisi.cksoft.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

Hi,

On Tue, 11 May 2004, Jie Liang wrote:

> Hi,
> How to use an internal variable?
> Original question was how to set a variable in postgresql?
> If I want to set a variable like start_date='2004-05-10';
> How could I use it in my SQL statement?
> E.g.
>
> Db> set start_date '2004-05-10'
> Db> select start_date as 'start date';
>
> It's not executable!

from doc/postgresql/html/sql-set.html

--snipp--
Synopsis

SET [ SESSION | LOCAL ] name { TO | = } { value | 'value' | DEFAULT }
SET [ SESSION | LOCAL ] TIME ZONE { timezone | LOCAL | DEFAULT }

...
...
...

name

Name of a settable run-time parameter.
Available parameters are documented in Section 16.4 and below.
--snipp--

that is you can only use SET to change specific predefined parameters.
It does not say you could use SET to store other data local to the database
session.

As far as I know there are no session local variables in postgresql.
I could use something like this myself. The only workaround I know of
to have data local to a session is to create a temporary table for the data.

There are local variables in plpgsql if you are just looking for local
variables.

Greetings
Christian

--
Christian Kratzer ck(at)cksoft(dot)de
CK Software GmbH http://www.cksoft.de/
Phone: +49 7452 889 135 Fax: +49 7452 889 136

In response to

  • \set at 2004-05-11 23:07:04 from Jie Liang

Browse pgsql-admin by date

  From Date Subject
Next Message Manfred Koizar 2004-05-12 10:17:27 Re: [PERFORM] Quad processor options
Previous Message Andrew McMillan 2004-05-12 08:58:13 Re: Quad processor options

Browse pgsql-sql by date

  From Date Subject
Next Message William Anthony Lim 2004-05-12 10:19:45 Re: working with schema
Previous Message Gary Stainburn 2004-05-12 10:02:31 view problem - too many rows out