Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id 18165475894 for ; Wed, 10 Jul 2002 07:00:42 -0400 (EDT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Wed Jul 10 13:00:43 2002 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id NAA04343; Wed, 10 Jul 2002 13:00:42 +0200 (METDST) From: Christoph Haller Message-Id: <200207101100.NAA06951@rodos> Subject: Re: Variables in PSQL To: traderx@gmx.ch (Roger Mathis) Date: Wed, 10 Jul 2002 13:00:42 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: <3d299272$0$1005$7402020d@newsfeed.sunrise.ch>; from "Roger Mathis" at Jul 9, 102 5:06 pm X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200207/132 X-Sequence-Number: 8511 > > 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