470,810 Members | 865 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

user defined variable per session

Hello,

I need to create user defined variable in every database session.
In Sybase ASA is equivalent:
CREATE VARIABLE name TYPE;

I need use this in views. Is it possible???

thanx, miso
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #1
3 2951

On Sunday, December 7, 2003, at 11:38 PM, Miso Hlavac wrote:
Hello,

I need to create user defined variable in every database session.
In Sybase ASA is equivalent:
CREATE VARIABLE name TYPE;

I need use this in views. Is it possible???


Would it be possible to use a temp (very simple) temp table to do this?
For example

CREATE TEMP TABLE variable (value INT);

for an integer variable. Then just use UPDATE and SELECT to set and
return the variable.

Michael
grzm myrealbox com
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2
> I need to create user defined variable in every database session.
In Sybase ASA is equivalent:
CREATE VARIABLE name TYPE;

I need use this in views. Is it possible???


What about

test=> \set myvar 5
test=> select :myvar;
?column?
----------
5
(1 row)

hth
cl.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #3
On Sun, 2003-12-07 at 19:57, Claudio Lapidus wrote:
I need to create user defined variable in every database session.
In Sybase ASA is equivalent:
CREATE VARIABLE name TYPE;

I need use this in views. Is it possible???


What about

test=> \set myvar 5
test=> select :myvar;
?column?
----------
5
(1 row)


But that is specific to psql. It's not something you can use in an
application, as you might the Sybase command.

--
Oliver Elphick Ol************@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"And if thy hand offend thee, cut it off; it is better
for thee to enter into life maimed, than having two
hands to go into hell, into the fire that never shall
be quenched." Mark 9:43
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jon Grieve | last post: by
3 posts views Thread by Simon Niederberger | last post: by
15 posts views Thread by Tom Nowak | last post: by
3 posts views Thread by c676228 | last post: by
reply views Thread by joseph conrad | last post: by
5 posts views Thread by Andy | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.