| From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
|---|---|
| To: | traderx(at)gmx(dot)ch (Roger Mathis) |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Variables in PSQL |
| Date: | 2002-07-10 13:00:42 |
| Message-ID: | 200207101100.NAA06951@rodos |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
>
> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Huxton | 2002-07-10 13:31:14 | Re: Error with DISTINCT and AS keywords |
| Previous Message | Christoph Haller | 2002-07-10 12:47:30 | Re: Problem on PostgreSQL (error code, store procedures) |