pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: traderx@gmx.ch
Cc: pgsql-sql@postgresql.org
Subject: Re: Variables in PSQL
Date: Wed, 10 Jul 2002 13:00:42 METDST
Message-ID: <200207101100.NAA06951@rodos> (raw)
In-Reply-To: <3d299272$0$1005$7402020d@newsfeed.sunrise.ch>

> 
> I'm trying to declare a variable in PostgreSQL, so I can save some values in
> it. After, I want to calculate with this variable.
> For example:
> 
> declare vp integer;
> select price into :vp from article where anr = 1;
> vp := vp + 1;
> update article set price = :vp where anr = 1;

AFAIK, you can do stuff like this only within a function. 
> 
> Is there a posibility to do that without creating a funktion?

What about 
update article set price =
 (select price + 1 from article where anr = 1)
where anr = 1; 

Regards, Christoph 



view thread (2+ messages)  latest in thread

Message-ID: <200207101100.NAA06951@rodos>
Permalink:  ../200207101100.NAA06951@rodos/
Also on:    postgresql.org/message-id/200207101100.NAA06951@rodos

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, traderx@gmx.ch
  Subject: Re: Variables in PSQL
  In-Reply-To: <200207101100.NAA06951@rodos>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox