Skip site navigation (1) Skip section navigation (2)

Re: [SQL] \set

From: "Jie Liang" <jie(at)stbernard(dot)com>
To: "Christian Kratzer" <ck(at)cksoft(dot)de>
Cc: <pgsql-admin(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] \set
Date: 2004-05-12 21:59:38
Message-ID: E7E213858379814A9AE48CA6754F5ECB363373@mail01.stbernard.com (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-sql
I am not talking about SET, I am talking about \set command.
Yes, I understand, plpgsql can work around it, but I think postgresql
should have a simple way to do it.
E.g.
Db>\set AAA 'whatever'
Db>\set
You will see AAA associate with 'whatever', it's an internal variable,
but how could I use it in my SQL query?


Thanks anyway.


Jie Liang

-----Original Message-----
From: Christian Kratzer [mailto:ck(at)cksoft(dot)de] 
Sent: Wednesday, May 12, 2004 3:13 AM
To: Jie Liang
Cc: pgsql-admin(at)postgresql(dot)org; pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] \set


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

Responses

pgsql-admin by date

Next:From: Bjoern MetzdorfDate: 2004-05-12 22:40:58
Subject: Quad processor options - summary
Previous:From: Gordon RossDate: 2004-05-12 20:20:51
Subject: Re: Problems dumping database from 7.3.1

pgsql-sql by date

Next:From: Tom LaneDate: 2004-05-12 23:05:37
Subject: Re: [SQL] \set
Previous:From: Bruno Wolff IIIDate: 2004-05-12 18:16:20
Subject: Re: How do i extract a certain bit from a bigint column

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group