From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "geraldo" <geraldo(at)umc(dot)br> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: function problem |
Date: | 2003-10-21 19:08:39 |
Message-ID: | 5306.1066763319@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"geraldo" <geraldo(at)umc(dot)br> writes:
> Can anybody tell me why the following code when activated
> by a select only affects the first line of the table???
> create or replace function increase(integer)
> returns void as 'update tab set price=price*(1+$1/100.0)'
> language sql;
Works fine here.
regression=# create table tab (price numeric);
CREATE TABLE
regression=# insert into tab values(1);
INSERT 154584 1
regression=# insert into tab values(10);
INSERT 154585 1
regression=# insert into tab values(100);
INSERT 154586 1
regression=# select * from tab;
price
-------
1
10
100
(3 rows)
regression=# create or replace function increase(integer)
regression-# returns void as 'update tab set price=price*(1+$1/100.0)'
regression-# language sql;
CREATE FUNCTION
regression=# select increase(42);
increase
----------
(1 row)
regression=# select * from tab;
price
--------------------------
1.42000000000000000000
14.20000000000000000000
142.00000000000000000000
(3 rows)
regression=#
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-10-21 21:39:26 | Re: plpgsql related question: intervals and variables |
Previous Message | Richard Huxton | 2003-10-21 19:02:04 | Re: [SQL] Alias-Error |